From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8837 invoked by alias); 12 Oct 2016 00:02:57 -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: 39612 Received: (qmail 10810 invoked from network); 12 Oct 2016 00:02:57 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.29):SA:0(0.0/5.0):. Processed in 0.404 secs); 12 Oct 2016 00:02:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=9qT2oaJVbH0cGLz3 LHlaEmnvZCg=; b=sbWBl1568ZADSRUpJ7RPiB7cLP3zUSmlZa8xFL1pgvuoCuP+ 78WGYPZYuLQxNa0dZsMeBHyfPC2ORZoBOpZyNrVvn0PFVpkV7/MWINyyASO1aVqj dO5DSlGz6ZLeEI270Qs1gRJkufTC7PkRnA0DgUV8vWkbfcOACRFeyU6NS2o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=9qT2oaJVbH0cGLz 3LHlaEmnvZCg=; b=lcHlZHVg3Ne9aJkB/IXZz/kg3Lpe8+xvV6CXAZkKq9inf69 6vb8d8Val++iSzNpURyzoHccgYmDKKmM4bYjf0be1h5q+VV5RxfKpvymkEu+ESr9 t/ok6/hpudcm7UHDzcKrnJCrwKnTaDLB204MiZEmM/3CQ+NWfyo0OWQyiXgM= X-Sasl-enc: 0AnTe6RUO1LnNXBQzL4ehrqoBx0h/UuiinVPrd2UYyzA 1476230572 Date: Wed, 12 Oct 2016 00:02:49 +0000 From: Daniel Shahaf To: Guilherme Salazar Cc: zsh-workers@zsh.org, Baptiste Daroussin Subject: Re: zsh make(1) completion on FreeBSD Message-ID: <20161012000249.GA32367@fujitsu.shahaf.local2> References: <20161011212150.GA24484@fujitsu.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Guilherme Salazar wrote on Tue, Oct 11, 2016 at 20:27:14 -0300: > Hi Daniel, > > > I'd like to see this fixed but I'm not on FreeBSD right now. Any chance > > you could write a patch? I think there are two approaches, either (a) > > figure out what incantation of BSD make is equivalent to «gmake -nspf > > $file», or (b) use the -d switch to ask make what are the targets, > > variables, and other things that _make-parseMakefile extracts. > > Baptiste (cc'ed) kindly sent me a patch he uses to get targets > completion [1]. Using it and adding variable completion, I got to the > following: > Thanks, both of you. > ```` > --- /usr/ports/shells/zsh/work/zsh-5.2/Completion/Unix/Command/_make > 2015-08-08 14:51:33.000000000 -0300 > +++ /usr/local/share/zsh/5.2/functions/Completion/Unix/_make > 2016-10-11 20:14:43.403084000 -0300 > @@ -268,7 +268,14 @@ > else > case "$OSTYPE" in > freebsd*) > - _make-parseMakefile $PWD < <(_call_program targets > "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null) > + if [[ $words[1] == *'gmake'* ]] > + then > + args="-nsp" > + else > + args="-nsdg1Fstdout" > + TARGETS+=(${=${(f)"$(_call_program targets \"$words[1]\" > -s -f "$file" -V.ALLTARGETS 2> /dev/null)"}}) The correct way to quote $words[1] would have been «${(q)words[1]}», but elements of $words are already command-line quoted so they don't need to be quoted again. That is: just using $words[1] directly would be correct. (modulo noglob, but don't worry about that) Since the patch was broken by your mailer, I'm reincluding it here so it's easier to review/apply. (You can usually send patches as attachments named *.txt to prevent munging and ensure a sane MIME type.) workers@: I've added this to my list to review, but my list is quite full nowadays, feel free to beat me to applying this. Thanks again for the patch. Cheers, Daniel (patch by Guilherme and bapt) diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index d10c8ee..de828bb 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -269,7 +269,14 @@ _make() { else case "$OSTYPE" in freebsd*) - _make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null) + if [[ $words[1] == *'gmake'* ]] + then + args="-nsp" + else + args="-nsdg1Fstdout" + TARGETS+=(${=${(f)"$(_call_program targets \"$words[1]\" -s -f "$file" -V.ALLTARGETS 2> /dev/null)"}}) + fi + _make-parseMakefile $PWD < <(_call_program targets "$words[1]" $args -f "$file" .PHONY 2> /dev/null) ;; *) _make-parseMakefile $PWD < $file > + fi > + _make-parseMakefile $PWD < <(_call_program targets > "$words[1]" $args -f "$file" .PHONY 2> /dev/null) > ;; > *) > _make-parseMakefile $PWD < $file > ```` > > It works well for bmake without breaking gmake. > > [1] https://people.freebsd.org/~bapt/_make.diff