From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3113 invoked by alias); 14 Jan 2017 17:46:33 -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: 22377 Received: (qmail 13529 invoked from network); 14 Jan 2017 17:46:33 -0000 X-Qmail-Scanner-Diagnostics: from mail.cs.uni-magdeburg.de 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(141.44.21.48):SA:0(-3.2/5.0):. Processed in 3.256097 secs); 14 Jan 2017 17:46:33 -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.2 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: jel+zsh@cs.uni-magdeburg.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at cs.uni-magdeburg.de does not designate permitted sender hosts) X-Authentication-Warning: trex.cs.ovgu.de: elkner set sender to jel+zsh@cs.uni-magdeburg.de using -f Date: Sat, 14 Jan 2017 18:46:22 +0100 From: Jens Elkner To: zsh-users@zsh.org Subject: Re: whence question Message-ID: <20170114174622.GA12641@trex.cs.ovgu.de> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170114064807.GA31410@fujitsu.shahaf.local2> User-Agent: Mutt/1.5.21 (2010-09-15) X-Milter: milter4j - Mail Filter for Java 1.1.4 (b767) X-Milter: ClamAV 0.98.1-jel on mail - Status: Clean X-RcptTo: zsh-users@zsh.org On Sat, Jan 14, 2017 at 06:48:07AM +0000, Daniel Shahaf wrote: > Ray Andrews wrote on Fri, Jan 13, 2017 at 22:09:54 -0800: ... > > I know that if a glob has no match it's passed verbatim so whence > > sees what it's supposed to see, > > 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 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, > > Right: while there are several ways to make a shell builtin command see > globs in arguments, the default behaviour of existing (released) > commands can't be changed for compatibility reasons. > > 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. I also prefer the default (i.e. use literal if no match), because it is IMHO safer than just dropping it (and opt. emit an err msg). However, especially in 'for' like statements, dropping it silently makes sense (is expected). To accomplish this in an easy way, ksh93 allows one to prefix the pattern with '~(N)' , e.g.: for F in ~(N)*.c ; do ls $F ; done or for F in ~(N)*.c ; do ls ${F%.c}/*.o ; done Would be nice, if zsh could do the same (and enhance compatibility) ... Have fun, jel. -- Otto-von-Guericke University http://www.cs.uni-magdeburg.de/ Department of Computer Science Geb. 29 R 027, Universitaetsplatz 2 39106 Magdeburg, Germany Tel: +49 391 67 52768