From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12723 invoked from network); 16 Aug 2004 07:43:33 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Aug 2004 07:43:33 -0000 Received: (qmail 31615 invoked from network); 16 Aug 2004 07:43:27 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Aug 2004 07:43:27 -0000 Received: (qmail 15298 invoked by alias); 16 Aug 2004 07:42:44 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7861 Received: (qmail 15287 invoked from network); 16 Aug 2004 07:42:43 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 16 Aug 2004 07:42:43 -0000 Received: (qmail 28865 invoked from network); 16 Aug 2004 07:41:34 -0000 Received: from unknown (HELO moonbase.zanshin.com) (167.160.213.139) by a.mx.sunsite.dk with SMTP; 16 Aug 2004 07:41:33 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i7G7fVvG031030 for ; Mon, 16 Aug 2004 00:41:31 -0700 Date: Mon, 16 Aug 2004 00:41:31 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: zsh-users@sunsite.dk Subject: Re: Slightly OT: Error-Handling in a Pipeline, preferably non-zsh In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-1.5 required=6.0 tests=BAYES_01 autolearn=no version=2.63 X-Spam-Hits: -1.5 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).