Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Suppressing failed glob patterns

On Dec 4, 2008, at 4:32 PM, Thorsten Kampe wrote:

* Michael Hernandez (Thu, 4 Dec 2008 16:26:37 -0500)>
On Dec 4, 2008, at 3:55 PM, Thorsten Kampe wrote:
I like the default in zsh for failed glob patterns (which errors
when no
file matches the pattern).

For example:
% rm file1.* file2.*
zsh: no matches found: file1.*

zsh never executes rm (which is fine). Additionially I would like to
rid of the error message in a script. Unfortunately redirecting stderr
does not work (because rm is never executed). Is there a way to keep
default and to suppress the error?!


I replied but didn't read carefully enough the first time, I see you
want to keep your default value, so maybe you don't want to setopt
no_nomatch. If this is the case you could start the function that
calls the rm command with:

setopt local_options no_nomatch

Yes, that's what I've been using until now. The problem is that I don't
know what a program that expects an argument will do if it receives no
argument. It might simply print help or await input from stdin. So the
default is for me exactly the best. Only the zsh's error is a kind of a
cosmetic problem in script (while interactively it's of course what I


Actually with no_nomatch set an argument is passed. See below:

setopt no_nomatch
rm fake*
rm: fake*: No such file or directory

See, the argument is passed but the * is passed as a literal * not as a pattern.

--Mike H

Messages sorted by: Reverse Date, Date, Thread, Author