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

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



On Sunday, August 15, 2004, at 10:42 PM, Bart Schaefer wrote:

On Sun, 15 Aug 2004, Aaron Davies wrote:

How do I do return-value error handling in the middle of a pipeline?

Or you could skip the awk and xargs entirely and use a while loop:

  ps aux | grep $name | grep -v grep | grep -v $0 |
  while read user pid remainder
  do
    $@ $pid
  done

What do you think of the solution I replied to Phillipe with, using xargs with "-r" and just checking the pipestatus to determine exit?

As a final note, you probably want "$@" in double quotes.

Really? I used it with multi-word commands (like "kill -9") with no problems.
--
    __                      __
   /  )                    /  )
  /--/ __. .__  ______    /  / __. , __o  _  _
 /  (_(_/|_/ (_(_) / (_  (__/_(_/|_\/ <__</_/_)_



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