* Suppressing failed glob patterns
@ 2008-12-04 20:55 Thorsten Kampe
2008-12-04 21:04 ` Frank Terbeck
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 20:55 UTC (permalink / raw)
To: zsh-users
Hi,
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 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?!
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 20:55 Suppressing failed glob patterns Thorsten Kampe
@ 2008-12-04 21:04 ` Frank Terbeck
2008-12-04 21:17 ` Michael Hernandez
2008-12-04 21:24 ` Thorsten Kampe
2008-12-04 21:13 ` N.J. Mann
` (2 subsequent siblings)
3 siblings, 2 replies; 19+ messages in thread
From: Frank Terbeck @ 2008-12-04 21:04 UTC (permalink / raw)
To: zsh-users
Thorsten Kampe <thorsten@thorstenkampe.de>:
> 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 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?!
Check these settings: <http://zshwiki.org/home/options/expn>
And also see what the difference between
% echo non-existing-file.*
and
% echo non-existing-file.*(N)
is.
That's documented in 'man zshexpn' and a list of available modifiers
and flags is also in <http://www.bash2zsh.com/zsh_refcard/refcard.pdf>.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 20:55 Suppressing failed glob patterns Thorsten Kampe
2008-12-04 21:04 ` Frank Terbeck
@ 2008-12-04 21:13 ` N.J. Mann
2008-12-04 21:21 ` Michael Hernandez
` (2 more replies)
2008-12-04 21:26 ` Michael Hernandez
2008-12-04 21:36 ` Stephane Chazelas
3 siblings, 3 replies; 19+ messages in thread
From: N.J. Mann @ 2008-12-04 21:13 UTC (permalink / raw)
To: Thorsten Kampe; +Cc: zsh-users
In message <gh9g43$rt5$1@ger.gmane.org>,
Thorsten Kampe (thorsten@thorstenkampe.de) 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 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?!
The answer is to use rm -f in your scripts.
Cheers,
Nick.
--
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:04 ` Frank Terbeck
@ 2008-12-04 21:17 ` Michael Hernandez
2008-12-04 21:24 ` Thorsten Kampe
1 sibling, 0 replies; 19+ messages in thread
From: Michael Hernandez @ 2008-12-04 21:17 UTC (permalink / raw)
To: Frank Terbeck; +Cc: zsh-users
On Dec 4, 2008, at 4:04 PM, Frank Terbeck wrote:
> Thorsten Kampe <thorsten@thorstenkampe.de>:
>> 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 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?!
>
> Check these settings: <http://zshwiki.org/home/options/expn>
>
> And also see what the difference between
>
> % echo non-existing-file.*
> and
> % echo non-existing-file.*(N)
>
> is.
>
> That's documented in 'man zshexpn' and a list of available modifiers
> and flags is also in <http://www.bash2zsh.com/zsh_refcard/
> refcard.pdf>.
>
You could use setopt no_nomatch and then rm would run, you'd get this:
% rm nowayjose*
rm: nowayhoe*: No such file or directory
Then you could redirect STDERR:
% rm nowayhoe* 2> /dev/null
[no error]
--Mike H
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:13 ` N.J. Mann
@ 2008-12-04 21:21 ` Michael Hernandez
2008-12-04 21:21 ` Frank Terbeck
2008-12-04 21:25 ` Thorsten Kampe
2 siblings, 0 replies; 19+ messages in thread
From: Michael Hernandez @ 2008-12-04 21:21 UTC (permalink / raw)
To: N.J. Mann; +Cc: Thorsten Kampe, zsh-users
On Dec 4, 2008, at 4:13 PM, N.J. Mann wrote:
> In message <gh9g43$rt5$1@ger.gmane.org>,
> Thorsten Kampe (thorsten@thorstenkampe.de) 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 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?!
>
> The answer is to use rm -f in your scripts.
>
Actually unless the no_nomatch option is set, rm -f non-existent-file*
will still cause zsh to tell you there's no match. Although with
no_nomatch set you will not need to redirect STDERR to suppress the
error that rm would give you.
--Mike H
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:13 ` N.J. Mann
2008-12-04 21:21 ` Michael Hernandez
@ 2008-12-04 21:21 ` Frank Terbeck
2008-12-04 21:25 ` Thorsten Kampe
2 siblings, 0 replies; 19+ messages in thread
From: Frank Terbeck @ 2008-12-04 21:21 UTC (permalink / raw)
To: zsh-users; +Cc: Thorsten Kampe
N.J. Mann <njm@njm.me.uk>:
> Thorsten Kampe (thorsten@thorstenkampe.de) wrote:
> > For example:
> > % rm file1.* file2.*
> > zsh: no matches found: file1.*
[...]
>
> The answer is to use rm -f in your scripts.
No it's not. Try it. With zsh's defaults.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:04 ` Frank Terbeck
2008-12-04 21:17 ` Michael Hernandez
@ 2008-12-04 21:24 ` Thorsten Kampe
2008-12-04 21:27 ` Bart Schaefer
` (2 more replies)
1 sibling, 3 replies; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 21:24 UTC (permalink / raw)
To: zsh-users
* Frank Terbeck (Thu, 4 Dec 2008 22:04:41 +0100)>
> Thorsten Kampe <thorsten@thorstenkampe.de>:
> > 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 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?!
>
> Check these settings: <http://zshwiki.org/home/options/expn>
>
> And also see what the difference between
>
> % echo non-existing-file.*
> and
> % echo non-existing-file.*(N)
>
> is.
>
> That's documented in 'man zshexpn' and a list of available modifiers
> and flags is also in <http://www.bash2zsh.com/zsh_refcard/refcard.pdf>.
Yes, I know about that. And that's what I've been using until now. But
it's also exactly what I not what. I don't what to give the command an
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).
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:13 ` N.J. Mann
2008-12-04 21:21 ` Michael Hernandez
2008-12-04 21:21 ` Frank Terbeck
@ 2008-12-04 21:25 ` Thorsten Kampe
2008-12-08 23:19 ` Benjamin R. Haskell
2 siblings, 1 reply; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 21:25 UTC (permalink / raw)
To: zsh-users
* N.J. Mann (Thu, 4 Dec 2008 21:13:15 +0000)>
> In message <gh9g43$rt5$1@ger.gmane.org>,
> Thorsten Kampe (thorsten@thorstenkampe.de) 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 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?!
>
> The answer is to use rm -f in your scripts.
rm was of course only an example. You can substitute ls or print or
whatever to see what I mean.
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 20:55 Suppressing failed glob patterns Thorsten Kampe
2008-12-04 21:04 ` Frank Terbeck
2008-12-04 21:13 ` N.J. Mann
@ 2008-12-04 21:26 ` Michael Hernandez
2008-12-04 21:32 ` Thorsten Kampe
2008-12-04 21:36 ` Stephane Chazelas
3 siblings, 1 reply; 19+ messages in thread
From: Michael Hernandez @ 2008-12-04 21:26 UTC (permalink / raw)
To: Thorsten Kampe; +Cc: zsh-users
On Dec 4, 2008, at 3:55 PM, Thorsten Kampe wrote:
> Hi,
>
> 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
> 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?!
>
> Thorsten
>
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
which will set the option for the duration of the function call but
return to the default when it's done. This way you have the benefits
of the option being set for the function without changing your default
shell behavior.
--Mike H
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:24 ` Thorsten Kampe
@ 2008-12-04 21:27 ` Bart Schaefer
2008-12-04 21:33 ` Thorsten Kampe
2008-12-04 21:29 ` Frank Terbeck
2008-12-04 21:30 ` Benjamin R. Haskell
2 siblings, 1 reply; 19+ messages in thread
From: Bart Schaefer @ 2008-12-04 21:27 UTC (permalink / raw)
To: zsh-users
On Thu, Dec 4, 2008 at 1:24 PM, Thorsten Kampe
<thorsten@thorstenkampe.de> wrote:
> 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).
Wrapping it in braces should do it:
{ rm non-existing-file.* } 2>/dev/null
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:24 ` Thorsten Kampe
2008-12-04 21:27 ` Bart Schaefer
@ 2008-12-04 21:29 ` Frank Terbeck
2008-12-04 21:30 ` Benjamin R. Haskell
2 siblings, 0 replies; 19+ messages in thread
From: Frank Terbeck @ 2008-12-04 21:29 UTC (permalink / raw)
To: zsh-users
Thorsten Kampe <thorsten@thorstenkampe.de>:
> * Frank Terbeck (Thu, 4 Dec 2008 22:04:41 +0100)>
> > Thorsten Kampe <thorsten@thorstenkampe.de>:
> > > 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
simpler.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:24 ` Thorsten Kampe
2008-12-04 21:27 ` Bart Schaefer
2008-12-04 21:29 ` Frank Terbeck
@ 2008-12-04 21:30 ` Benjamin R. Haskell
2008-12-04 21:39 ` Stephane Chazelas
2 siblings, 1 reply; 19+ messages in thread
From: Benjamin R. Haskell @ 2008-12-04 21:30 UTC (permalink / raw)
To: Zsh Users
On Thu, 4 Dec 2008, Thorsten Kampe wrote:
> Yes, I know about that. And that's what I've been using until now. But
> it's also exactly what I not what. I don't what to give the command an
> 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).
>
> Thorsten
You want both of the things suggested in this thread ('-f' and '(N)'):
# original problem
$ rm non-existing-file.*
zsh: no matches found: non-existing-file.*
# '-f' doesn't solve 'no matches'
$ rm -f non-existing-file.*
zsh: no matches found: non-existing-file.*
# '(N)' doesn't solve the 'missing operand'
$ rm non-existing-file.*(N)
rm: missing operand
Try `rm --help' for more information.
# '(N)' solves one, '-f' solves the other
$ rm -f non-existing-file.*(N)
$
Best,
Ben
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:26 ` Michael Hernandez
@ 2008-12-04 21:32 ` Thorsten Kampe
2008-12-04 21:44 ` Michael Hernandez
0 siblings, 1 reply; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 21:32 UTC (permalink / raw)
To: zsh-users
* 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
> > 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?!
> >
> > Thorsten
> >
>
>
> 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
want).
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:27 ` Bart Schaefer
@ 2008-12-04 21:33 ` Thorsten Kampe
0 siblings, 0 replies; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 21:33 UTC (permalink / raw)
To: zsh-users
* Bart Schaefer (Thu, 4 Dec 2008 13:27:50 -0800)>
> On Thu, Dec 4, 2008 at 1:24 PM, Thorsten Kampe
> <thorsten@thorstenkampe.de> wrote:
> > 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).
>
> Wrapping it in braces should do it:
>
> { rm non-existing-file.* } 2>/dev/null
Right. Surprisingly (for me) it does. Thanks.
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 20:55 Suppressing failed glob patterns Thorsten Kampe
` (2 preceding siblings ...)
2008-12-04 21:26 ` Michael Hernandez
@ 2008-12-04 21:36 ` Stephane Chazelas
2008-12-04 21:40 ` Thorsten Kampe
3 siblings, 1 reply; 19+ messages in thread
From: Stephane Chazelas @ 2008-12-04 21:36 UTC (permalink / raw)
To: Thorsten Kampe; +Cc: zsh-users
On Thu, Dec 04, 2008 at 09:55:37PM +0100, 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 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?!
[...]
{rm file1.* file2.*} 2> /dev/null
--
Stéphane
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:30 ` Benjamin R. Haskell
@ 2008-12-04 21:39 ` Stephane Chazelas
0 siblings, 0 replies; 19+ messages in thread
From: Stephane Chazelas @ 2008-12-04 21:39 UTC (permalink / raw)
To: Benjamin R. Haskell; +Cc: Zsh Users
On Thu, Dec 04, 2008 at 04:30:58PM -0500, Benjamin R. Haskell wrote:
> On Thu, 4 Dec 2008, Thorsten Kampe wrote:
>
>> Yes, I know about that. And that's what I've been using until now. But
>> it's also exactly what I not what. I don't what to give the command an
>> 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).
>>
>> Thorsten
>
>
> You want both of the things suggested in this thread ('-f' and '(N)'):
>
> # original problem
> $ rm non-existing-file.*
> zsh: no matches found: non-existing-file.*
>
> # '-f' doesn't solve 'no matches'
> $ rm -f non-existing-file.*
> zsh: no matches found: non-existing-file.*
>
> # '(N)' doesn't solve the 'missing operand'
> $ rm non-existing-file.*(N)
> rm: missing operand
> Try `rm --help' for more information.
>
> # '(N)' solves one, '-f' solves the other
> $ rm -f non-existing-file.*(N)
> $
[...]
But
rm -f file1.*(N) file2.*(N)
would silently remove file1.xxx while there's no file2.* file
which the OP didn't want (he wanted rm not to be run if any one
pattern doesn't match any file).
--
Stéphane
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:36 ` Stephane Chazelas
@ 2008-12-04 21:40 ` Thorsten Kampe
0 siblings, 0 replies; 19+ messages in thread
From: Thorsten Kampe @ 2008-12-04 21:40 UTC (permalink / raw)
To: zsh-users
* Stephane Chazelas (Thu, 4 Dec 2008 21:36:17 +0000)>
> On Thu, Dec 04, 2008 at 09:55:37PM +0100, 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 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?!
> [...]
>
> {rm file1.* file2.*} 2> /dev/null
Thanks, also :)
Thorsten
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:32 ` Thorsten Kampe
@ 2008-12-04 21:44 ` Michael Hernandez
0 siblings, 0 replies; 19+ messages in thread
From: Michael Hernandez @ 2008-12-04 21:44 UTC (permalink / raw)
To: Thorsten Kampe; +Cc: zsh-users
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
>>> 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?!
>>>
>>> Thorsten
>>>
>>
>>
>> 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
> want).
>
> Thorsten
>
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Suppressing failed glob patterns
2008-12-04 21:25 ` Thorsten Kampe
@ 2008-12-08 23:19 ` Benjamin R. Haskell
0 siblings, 0 replies; 19+ messages in thread
From: Benjamin R. Haskell @ 2008-12-08 23:19 UTC (permalink / raw)
To: Zsh Users
[Sorry -- responded from the wrong address, and didn't get the mailing
list notice until today]
On Thu, 4 Dec 2008, Thorsten Kampe wrote:
> rm was of course only an example. You can substitute ls or print or
> whatever to see what I mean.
>
> Thorsten
You might also be interested in the '--no-run-if-empty' flag to 'xargs'.
pros: doesn't depend on nullglob setting, shell portability (e.g.
non-Zsh), more general
cons: more complex, depends on 'find' and 'xargs'
(Probably not the best solution, but it can't hurt to know.)
Examples:
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty rm Z
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty ls -l Z
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty echo Z
# Unrelated to the current problem, but somewhere I found it useful:
# renice Audacious if it's running
pgrep audacious | xargs --no-run-if-empty sudo renice -5
Best,
Ben
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2008-12-08 23:20 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-04 20:55 Suppressing failed glob patterns Thorsten Kampe
2008-12-04 21:04 ` Frank Terbeck
2008-12-04 21:17 ` Michael Hernandez
2008-12-04 21:24 ` Thorsten Kampe
2008-12-04 21:27 ` Bart Schaefer
2008-12-04 21:33 ` Thorsten Kampe
2008-12-04 21:29 ` Frank Terbeck
2008-12-04 21:30 ` Benjamin R. Haskell
2008-12-04 21:39 ` Stephane Chazelas
2008-12-04 21:13 ` N.J. Mann
2008-12-04 21:21 ` Michael Hernandez
2008-12-04 21:21 ` Frank Terbeck
2008-12-04 21:25 ` Thorsten Kampe
2008-12-08 23:19 ` Benjamin R. Haskell
2008-12-04 21:26 ` Michael Hernandez
2008-12-04 21:32 ` Thorsten Kampe
2008-12-04 21:44 ` Michael Hernandez
2008-12-04 21:36 ` Stephane Chazelas
2008-12-04 21:40 ` Thorsten Kampe
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).