From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,MALFORMED_FREEMAIL,RCVD_IN_DNSWL_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id c619fa70 for ; Thu, 2 Jan 2020 21:05:57 +0000 (UTC) Received: (qmail 14495 invoked by alias); 2 Jan 2020 18:01:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45196 Received: (qmail 5675 invoked by uid 1010); 2 Jan 2020 18:01:24 -0000 X-Qmail-Scanner-Diagnostics: from sonic304-22.consmr.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25677. spamassassin: 3.4.2. Clear:RC:0(77.238.179.147):SA:0(-0.6/5.0):. Processed in 1.644793 secs); 02 Jan 2020 18:01:24 -0000 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 77.238.179.147 as permitted sender) X-YMail-OSG: 2LOSMYsVM1l7Hlk5ZlpwGOvOiCmS0T2jiIWAIP8imIr2TLUNZU3OAyMM65l8.vI pqf_4M0lFGKN4thqo_2LMWMTU8xWH2WpJC6CrxjVhovjTcH7C8vaYxBy5Jz1IALiCmN1PQdtbbvO BQQ8hjgQrDkh3a7ZqVVMz9yyzJJUJl9qzMDtAb584bLHMcECDlcWENycT_1B_w.LKqtsAI14oBRR zd8k_o82uiF_cgZExTbbiCkVn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J8PBGlDrall_V9Yyp9ZulpWzxPGuU9NLEk9taYUe2K4cSik2xwmZtZ8ZONtHis lpuDCfDMC9.iS8MEcn0YdDTD4KeH8d8mO_ospKgh0qM7oQcKxe_UxTDRlwZaXy1mTkvNpGyS7Xxx ttEyN4DDSg.EMY3d2 cc: Zsh workers In-reply-to: <20191222043131.sosy5gg5aevuu765@tarpaulin.shahaf.local2> From: Oliver Kiddle References: <2024-1573077069.922525.ref@CD2K.zG8N.q383> <2024-1573077069.922525@CD2K.zG8N.q383> <20191222043131.sosy5gg5aevuu765@tarpaulin.shahaf.local2> To: Daniel Shahaf Subject: Re: PATCH: following -C option in make completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <35583.1577988041.1@hydra> Date: Thu, 02 Jan 2020 19:00:41 +0100 Message-ID: <35584-1577988041.646122@XRPl.0Soq._2V2> X-Mailer: WebService/1.1.14873 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_181) Daniel Shahaf wrote: > % make -C fo > [no matches] > > It does work if I revert this patch. The easy quick fix would be to use _directories for -C. That's only wrong if multiple -C options are used which is obscure enough that it didn't occur to me when I wrote the patch. The state is used for -C's argument itself because of that GNU specific feature of allowing -C to be repeatable. But after make -C , $opt_args[-C] is set to the empty string for the current -C option. Hence the breakage you observed. I think it is preferable to use $opt_args over scanning $words as in the original code. That'll only be wrong if the user mixes -C and --directory (the old code ignored --directory completely so I don't feel bad about that). The following patch changes the basedir assignment. The new expansion is especially gnarly so I'd appreciate if you could give it some testing. It has to: - (temporarily) convert quoted colons to nulls - remove one level of shell quoting - prepend $PWD: so the current directory is the default and to workaround problems with splitting giving a string not an array when there's no separator at all - split on colons and use (@) and double quotes to avoid losing a final empty element - expand named directories for each element - throw away initial elements if a later one is absolute - drop the last element for -C (but not -I) - turn nulls back into colons - join elements with / Oliver diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 06971f07a..21ed56184 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -120,12 +120,12 @@ _make-parseMakefile () { _make() { - local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir + local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir nul=$'\0' local context state state_descr line local -a option_specs local -A VARIABLES VAR_ARGS opt_args local -aU TARGETS keys - local ret=1 + local -i cdir=-1 ret=1 # VAR=VAL on the current command line for tmp in $words; do @@ -142,7 +142,7 @@ _make() { incl="(-|)include" option_specs=( '(-B --always-make)'{-B,--always-make}'[unconditionally make all targets]' - '*'{-C,--directory=}'[change directory first]:change to directory:->dir' + '*'{-C,--directory=}'[change directory first]:change to directory:->cdir' '-d[print lots of debug information]' '--debug=-[print various types of debug information]:debug options:->debug' '(-e --environment-overrides)'{-e,--environment-overrides}'[environment variables override makefiles]' @@ -177,7 +177,7 @@ _make() { # Basic make options only. incl=.include option_specs=( - '-C[change directory first]:directory:->dir' + '-C[change directory first]:directory:->cdir' '-I[include directory for makefiles]:directory:->dir' '-f[specify makefile]:makefile:->file' '-o[specify file not to remake]:file not to remake:->file' @@ -188,11 +188,12 @@ _make() { _arguments -s $option_specs \ '*:make target:->target' && ret=0 - basedir=${(Q)~opt_args[-C]:-${opt_args[--directory]}} - VAR_ARGS[CURDIR]="${basedir:=$PWD}" + [[ $state = cdir ]] && cdir=-2 + basedir=${(j./.)${${~"${(@s.:.):-$PWD:${(Q)${opt_args[-C]:-$opt_args[--directory]}//\\:/$nul}}"}[(R)/*,cdir]}//$nul/:} + VAR_ARGS[CURDIR]="${basedir}" case $state in - (dir) + (*dir) _description directories expl "$state_descr" _files "$expl[@]" -W $basedir -/ && ret=0 ;;