From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7665 invoked by alias); 14 Jan 2017 16:36:28 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22374 Received: (qmail 29471 invoked from network); 14 Jan 2017 16:36:28 -0000 X-Qmail-Scanner-Diagnostics: from mta04.eastlink.ca 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(24.224.136.10):SA:0(-3.9/5.0):. Processed in 0.703999 secs); 14 Jan 2017 16:36:28 -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=-3.9 required=5.0 tests=RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.eastlink.ca designates 24.224.136.10 as permitted sender) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=windows-1252; format=flowed X-Authority-Analysis: v=2.2 cv=ZvqvEJzG c=1 sm=1 tr=0 a=28Ntk8jg+Dho8ABWn/CRtA==:117 a=28Ntk8jg+Dho8ABWn/CRtA==:17 a=N659UExz7-8A:10 a=fmExf1uKU-RzndLNPC8A:9 a=pILNOxqGKmIA:10 X-EL-IP-NOAUTH: 24.207.16.108 Subject: Re: whence question To: zsh-users@zsh.org References: <652bcc3f-7365-2e52-d39c-8576278606bc@eastlink.ca> <7b890e89-d01b-ab5c-32bf-b75bfa8d945c__41234.9168131643$1484374276$gmane$org@eastlink.ca> <20170114064807.GA31410@fujitsu.shahaf.local2> From: Ray Andrews Message-id: Date: Sat, 14 Jan 2017 08:36:21 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 In-reply-to: <20170114064807.GA31410@fujitsu.shahaf.local2> On 13/01/17 10:48 PM, Daniel Shahaf wrote: > > That's only true when 'setopt nonomatch' is in effect, which is not the > default. By default, globs that have no match are considered errors. > The NULL_GLOB option selects a third mode. See: > > % cd $(mktemp -d) > % echo foo* > zsh: no matches found: foo* > % (setopt nullglob; echo foo*) | nl -ba > > % (setopt nonomatch; echo foo*) > foo* > % I'll take a closer look at those options, I'm always terrified that if I play with them I'll set a landmine what will blow up on me latter and I'll forget what it is that I changed or why things are broken. Gotta make sure that nullglob and nonomatch don't trip over each other. But first experiments: > $ unsetopt nullglob; unsetopt nonomatch; whence -ma grub-r* > $ unsetopt nullglob; setopt nonomatch; whence -ma grub-r* > $ setopt nullglob; setopt nonomatch; whence -ma grub-r* > $ setopt nullglob; unsetopt nonomatch; whence -ma grub-r* Does that contradict? Nuthin' works. >> [...] I can see that without 'noglob' the shell's zeal for expanding >> globs is in more or less direct conflict with the intention of the 'm' >> switch which supposes that whence will handle globing itself. I can >> also see that that might not be fixable even in theory for reasons of >> consistency, > Also, the existing design has merits: *every* external and builtin > command parses "words with globbing metacharacters" the same way. > «echo *foo» and «whence *foo» and «bar *foo» are all subject to the > same rules. The rules are consistent for everybody. That's a feature. Well, consistency trumps convenience. Still I'd argue that my original example really is a gotcha, it's not something that would ever (?) be anticipated. Just being devil's advocate here of course but in this case does not the 'm' switch in effect 'state' an exception? That is, is it not an explicit request to change the rules vis a vis globing? Without 'm' I have no expectation that whence has any special power vis a vis globing (globbing?) but with 'm' I expect that it does. Can we have intuitive behaviour and consistency if it was a stated principal that 'm' (and any other such devices) are immune to the artifact of the local match which is in no way a 'natural' target for whence anyway? IOW 'whence -ma grub-r*' should never be anything other than a search for natural whence targets and the local match could be seen as an error. Delicate tho, maybe not.