From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25950 invoked from network); 3 May 1998 00:52:15 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 3 May 1998 00:52:15 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id UAA03728; Sat, 2 May 1998 20:49:01 -0400 (EDT) Resent-Date: Sat, 2 May 1998 20:48:50 -0400 (EDT) Message-ID: <19980502205020.11096@astaroth.nit.gwu.edu> Date: Sat, 2 May 1998 20:50:20 -0400 From: Sweth Chandramouli To: zsh-users@math.gatech.edu Subject: Re: exit value of intermediate program in pipe Mail-Followup-To: zsh-users@math.gatech.edu References: <199805022224.QAA03113@ipecac.Central.Sun.COM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89 In-Reply-To: <199805022224.QAA03113@ipecac.Central.Sun.COM> Resent-Message-ID: <"xx5YD.0.fv.mxxIr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1497 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Sat, May 02, 1998 at 04:24:40PM -0600, Steve Talley wrote: > I have a function foo: > > 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. if running /bin/blah isn't very compute-intensive, and doesn't change its own subsequent input in any way (so that it can be run twice consecutively with the same results), why not try foo () { /bin/blah > /dev/null ; exitstatus=$? /bin/blah | grep -v "bar" return $exitstatus } in theory, there should be some cleaner way to do this using a two-way pipe, but i've never been able to get them to work correctly. i think there are ways to export the value of a variable out of a code block, which would also do the trick, but { /bin/blah ; export exitstatus=$? } | grep -v "bar" ; return $exitstatus , which is how i thought that was done, didn't work. -- sweth. -- "Countin' on a remedy I've counted on before Goin' with a cure that's never failed me What you call the disease I call the remedy" -- The Mighty Mighty Bosstones