Per the documentation, ~
can be used as glob operator when EXTENDED_GLOB
is set, allowing constructs like
print -rl glob*~globA*~glob*B
so anything that matches glob*
but does not match globA*
and glob*B
.
All right:
touch file{1,2,3,4{,5}}
setopt extendedglob
now
print -rl file*~f*3~file4*
behaves as expected:
file1
file2
but when an empty pattern is used
print -rl file*~f*3~~file4*
prints
file1
file2
file3
It looks like only the last pattern is used to filter the results of the 1st glob (2nd and 3rd - which is empty - are ignored).
print -rl file*~f*3~file4*~~
produces
file1
file2
file4
file45
so now only the 2nd one is used...
What's weird is that if the pattern after the 1st tilde is empty it does not work at all e.g.
print -rl file*~~f*3~file4*
errors out with
zsh: no matches found: file*~~f*3~file4*
What am I missing here ?
this is with zsh 5.3.1
if it matters...
~~
is literal and not an operator.