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

Re: Slightly OT: Error-Handling in a Pipeline, preferably non-zsh



On Sun, 15 Aug 2004, Aaron Davies wrote:

> >   ps aux | grep $name | grep -v grep | grep -v $0 |
> 
> What do you think of the solution I replied to Phillipe with, using 
> xargs with "-r" and just checking the pipestatus to determine exit?

It should work fine.  It just isn't what (I thought) you were asking for 
-- it still runs both awk and xargs even when the greps find nothing.

> > As a final note, you probably want "$@" in double quotes.
> 
> Really? I used it with multi-word commands (like "kill -9") with no 
> problems.

What happens when one of the arguments of the command is a quoted word 
containing spaces?  E.g. supposing your "generalized killall" is named
"runcommandonpidof" (since you've never told us what it _is_ called), try

  sleep 30 &
  runcommandonpidof sleep print -l "this should be on one line"

(and try it in a non-zsh shell, where word splitting applies; no cheating 
by letting zsh preserve the quoting for you, you asked for portability).



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