From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8291 invoked by alias); 28 Apr 2015 00:46:05 -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: X-Seq: 34980 Received: (qmail 27884 invoked from network); 28 Apr 2015 00:46:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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== MIME-Version: 1.0 X-Received: by 10.67.15.102 with SMTP id fn6mr27602341pad.120.1430181955879; Mon, 27 Apr 2015 17:45:55 -0700 (PDT) Date: Mon, 27 Apr 2015 20:45:55 -0400 Message-ID: Subject: Proposed patches for make completion bugs From: Jared Ahern To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary=001a11343eca71c9310514be2f87 --001a11343eca71c9310514be2f87 Content-Type: text/plain; charset=UTF-8 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 --001a11343eca71c9310514be2f87--