Zsh Mailing List Archive
Messages sorted by:
Re: whence question
On 13/01/17 10:48 PM, Daniel Shahaf wrote:
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
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*)
$ 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
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.
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.
Messages sorted by: