From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26938 invoked from network); 9 Dec 2021 21:19:33 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Dec 2021 21:19:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3LkGlvJ5zR6hlanHFZw8Dm8s8QTvyxiLO5mryZ/Kki0=; b=qUtbsTQxXnQygu48IUHCsU5xlo J9ugXoGl70Z7SXyaYduKmstTOeBeCC9UB1tRKRW4tG8tFGtMTlev0iVLiU4zRrHNyhi/foYRcZTH+ GDsKxq2l1d2UNTo3wZnbo8AgBZucd5x00QQceMWyjbdoBnbkloM921XPRajMkWikfOT3kGo+QXONm MBQS4j1bq7lAOMfh0SjrorPcXqa6sCaZ+Q8RnJyPIWIHE0UB4rs14uQBDHWpWG05oo7oTSIem1bNR 7CXMWKSmL19o2ycARgs7eclYO5eX2oVKisLzqAiQHy/YOfWlaSNsAJkdxoMBkueAt+zyZwp2g4biD iWLmmxqw==; Received: from authenticated user by zero.zsh.org with local id 1mvQpA-000PKa-35; Thu, 09 Dec 2021 21:19:32 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mvQou-000P32-9d; Thu, 09 Dec 2021 21:19:16 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mvQot-000Ngm-7J; Thu, 09 Dec 2021 22:19:15 +0100 cc: Marlon Richert , Zsh hackers list In-reply-to: From: Oliver Kiddle References: <64846-1639005414.316056@22FL.WcIa.VGfN> To: Bart Schaefer Subject: Re: [FEATURE][PATCH] Complete local executables with ./ prefix, if prefix-needed is false MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <91062.1639084755.1@hydra> Date: Thu, 09 Dec 2021 22:19:15 +0100 Message-ID: <91063-1639084755.223147@qdDe.8sM-.6adi> X-Seq: 49645 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Bart Schaefer wrote: > > The fake style is looked up in _description so a dummy call to it is one > > option. The patch below adds that but I'd be interested in any thoughts > > on that. > > Is it going to matter that this happens before command-path is > consulted? And before the defs array is passed to _alternative? I don't think so, other than the point I already mentioned about the return status from _command_names not accounting for the fake matches. fake is usually handled early because _description needs to be called before compadd. > > path=( $cmdpath:A ) when the command-path style is set. That resolves > Does that have any unexpected interaction with PATH_DIRS ? Not with the actual path_dirs functionality because of path being local in the function. In terms of completion down in _path_commands that still works. It ought to filter out "." from $path anyway to avoid duplicated completions. It also doesn't add a / suffix for the directories and didn't account for symlinks to executables. So I've included a patch against the completion handling for path_dirs. :A will subvert the filtering of "." but the effect is very minor. I'm unsure whether command-path should perhaps be looked up before the $path[(r).] check in _command_names. Oliver diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands index 66795ae0f..4d5a6c5af 100644 --- a/Completion/Unix/Type/_path_commands +++ b/Completion/Unix/Type/_path_commands @@ -87,18 +87,19 @@ fi # 'if' block move up to the "_command_names -" branch of _command_names? if [[ -o path_dirs ]]; then local -a path_dirs - path_dirs=(${^path}/*(/N:t)) - (( ${#path_dirs} )) && - _wanted path-dirs expl 'directory in path' compadd "$@" -a path_dirs && ret=0 if [[ $PREFIX$SUFFIX = */* ]]; then + path_dirs=( ${path:#.} ) # Find command from path, not hashed - _wanted commands expl 'external command' _path_files -W path -g '*(*)' && - ret=0 + _wanted commands expl 'external command' _path_files -W path_dirs -g '*(-*)' && ret=0 + else + path_dirs=(${^path}/*(/N:t)) + (( ${#path_dirs} )) && + _wanted path-dirs expl 'directory in path' compadd "$@" -S / -a path_dirs && ret=0 fi fi -return $ret +return ret } _path_commands "$@"