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

Re: Suppressing failed glob patterns

Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>:
> * Frank Terbeck (Thu, 4 Dec 2008 22:04:41 +0100)> 
> > Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>:
> > > For example:
> > > % rm file1.* file2.*                                                          
> > > zsh: no matches found: file1.*
> > > 
> > > zsh never executes rm (which is fine). Additionially I would like to get 
> > > 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 the 
> > > default and to suppress the error?!
> > 
> empty pattern. Compare:
> % rm non-existing-file.*
> zsh: no matches found: non-existing-file.*
> % rm non-existing-file.*(N)
> rm: missing operand
> Try `rm --help' for more information.
> I just want rm not to be executed (like it's the default) but without 
> the error (which is fine when I do it interactively but not in a 
> script).

AFAIK, there's no way to do that with a simple option. See the link to
zshwiki.org about that, too. You'd have to check for yourself if a
file matches your pattern and then conditionally run rm.

In that case, just do add -f to rm's options. That'll be a lot

Regards, Frank

In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925

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