From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26528 invoked from network); 3 May 1998 02:13:38 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 3 May 1998 02:13:38 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id WAA04930; Sat, 2 May 1998 22:10:11 -0400 (EDT) Resent-Date: Sat, 2 May 1998 22:08:36 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980502190831.ZM29269@candle.brasslantern.com> Date: Sat, 2 May 1998 19:08:31 -0700 In-Reply-To: <199805022224.QAA03113@ipecac.Central.Sun.COM> Comments: In reply to talley@boulder.Central.Sun.COM (Steve Talley) "exit value of intermediate program in pipe" (May 2, 4:24pm) References: <199805022224.QAA03113@ipecac.Central.Sun.COM> X-Mailer: Z-Mail (4.0b.820 20aug96) To: talley@boulder.Central.Sun.COM (Steve Talley), zsh-users@math.gatech.edu Subject: Re: exit value of intermediate program in pipe MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"MaGLZ1.0.8A1.Z6zIr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1499 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu } foo () { } /bin/blah | grep -v "foo" } } } } I would like this function to exit with the exit value from the } /bin/blah process, but it exits with the exit value from grep instead. You can do this: foo() { /bin/blah >>(grep -v "foo") } That effectively runs grep in the background and blah in the foreground, while still connecting them with a pipe. Then you get the exit status of blah, but with the side effect that the function returns as soon as blah finishes, without waiting for the grep -- which may not be what you want. I don't think there's any other way to do this without using a temp file. foo() { local outfile=${TMPPREFIX}blah.out /bin/blah > $outfile local exitval=$? grep -v "foo" $outfile command rm -f $outfile return $exitval } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com