Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Proposed patches for make completion bugs
- X-seq: zsh-workers 34980
- From: Jared Ahern <jared.ahern@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Proposed patches for make completion bugs
- Date: Mon, 27 Apr 2015 20:45:55 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=mK4Mh4eGSx3hX22VURW79lCbze2WmhvcIdfTKWUmsi8=; b=XY4feFGPT4nCaExwLNAA5Gr/xWiVqd1Z1s64BRCe4XqJYnq0s0VeIUxIuLf+Q3902X qAUUUJMPFSJpOI9uTa6u2fkEZivDuN3+gbXMqOfPfipRreomn25xoi9ZrwTjFsjyaWsp faSInjzwaa7uJTd3B/SOa/D4vP0mTomN1FVIXXDcQClUwG1CuZsZBhMfCx99DlgJuD1N CrYfnbOf0OoAJU8kkXoE4JnDJRjhBPNMfordx9NevnVjyTR1C0nezGHwq6TOtNaNAJzi QZA4frsXNFM4Wf5sL2HfGFzwSo9yBJRSaJt8Nt08A93vdH92yAZ6TJG37jSqTOawoZm1 Jeiw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello,
I've been using zsh for years and it is excellent. One thing that I
realized recently was that it was not completing the "make" command
correctly, so I investigated, using version 5.0.7 as a base. As far as I
can tell, my problems resulted from two issues. The first was that zsh did
not recognize the ?= or ::= forms of variable assignment in at least GNU
make. This should be corrected with this patch:
diff -rup a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
--- a/Completion/Unix/Command/_make 2013-11-27 14:00:19.000000000 -0500
+++ b/Completion/Unix/Command/_make 2015-04-27 20:17:05.000000000 -0400
@@ -64,18 +64,18 @@ _make-parseMakefile () {
while read input
do
case "$input " in
- # VARIABLE = value
- ([[:alnum:]][[:alnum:]_]#[ $TAB]#=*)
- var=${input%%[ $TAB]#=*}
+ # VARIABLE = value OR VARIABLE ?= value
+ ([[:alnum:]][[:alnum:]_]#[ $TAB]#(\?|)=*)
+ var=${input%%[ $TAB]#(\?|)=*}
val=${input#*=}
val=${val##[ $TAB]#}
VARIABLES[$var]=$val
;;
- # VARIABLE := value
+ # VARIABLE := value OR VARIABLE ::= value
# Evaluated immediately
- ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*)
- var=${input%%[ $TAB]#:=*}
+ ([[:alnum:]][[:alnum:]_]#[ $TAB]#:(:|)=*)
+ var=${input%%[ $TAB]#:(:|)=*}
val=${input#*=}
val=${val##[ $TAB]#}
val=$(_make-expandVars $val)
The second issue is that as far as I can tell, expansion of "make"
variables was not happening at all. This should be addressed by this
separate second patch, although I may have induced regressions of which I
am unaware. I wasn't 100% sure what the original intent was for the
_make-expandVars function, but my cases appear to be fixed.
diff -rup a/Completion/Unix/Command/_make c/Completion/Unix/Command/_make
--- a/Completion/Unix/Command/_make 2013-11-27 14:00:19.000000000 -0500
+++ c/Completion/Unix/Command/_make 2015-04-27 20:17:17.000000000 -0400
@@ -7,51 +7,52 @@ _make-expandVars() {
local open close var val front ret tmp=$1
front=${tmp%%\$*}
+ tmp=${tmp#$front}
case $tmp in
- (\(*) # Variable of the form $(foobar)
+ (\$\(*) # Variable of the form $(foobar)
open='('
close=')'
;;
- ({*) # ${foobar}
+ (\${*) # ${foobar}
open='{'
close='}'
;;
- ([[:alpha:]]*) # $foobar. This is exactly $(f)oobar.
+ (\$[[:alpha:]]*) # $foobar. This is exactly $(f)oobar.
open=''
close=''
- var=${(s::)var[1]}
+ var=${(s::)tmp[2]}
;;
- (\$*) # Escaped $.
+ (\$\$*) # Escaped $.
print -- "${front}\$$(_make-expandVars ${tmp#\$})"
return
;;
(*) # Nothing left to substitute.
- print -- $tmp
+ print -- ${front}${tmp}
return
;;
esac
if [[ -n $open ]]
then
- var=${tmp#$open}
+ var=${tmp#\$$open}
var=${var%%$close*}
fi
case $var in
([[:alnum:]_]#)
val=${VARIABLES[$var]}
- ret=${ret//\$$open$var$close/$val}
+ ret=${tmp//\$$open$var$close/$val}
;;
(*)
# Improper variable name. No replacement.
# I'm not sure if this is desired behavior.
front+="\$$open$var$close"
- ret=${ret/\$$open$var$close/}
+ ret=${tmp/\$$open$var$close/}
;;
esac
The sourceforge site for zsh indicated that proposed patches should be sent
to this email address, but please email me if I should do anything
different, or if you need more info. Hopefully I've included all the
correct patch text. With luck, these two changes will make it into a future
version of zsh!
Thanks,
Jared
Messages sorted by:
Reverse Date,
Date,
Thread,
Author