ksh script, exit status and pipe
From: Ian Wilson (scobloke2_at_infotop.co.uk)
Date: 08/25/04
- Previous message: Doug Freyburger: "Re: filesystem or rawdevice"
- Next in thread: Stephane CHAZELAS: "Re: ksh script, exit status and pipe"
- Reply: Stephane CHAZELAS: "Re: ksh script, exit status and pipe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 25 Aug 2004 11:00:44 +0000 (UTC)
I want to execute a command, redirect stderr and tee stdout
e.g.
tar ... 2>foo.err | tee foo.log
however I also want to capture the exit status of the first command
tar ... 2>foo.err | tee foo.log
exitstatus = $?
simply gets the exit status of tee of course
tar ... || exitstatus=$? 2>foo.err | tee foo.log
always sets exitstatus to zero, looks like I need to establish some
precedence but brackets don't seem to help.
Is there an idiom for this?
Maybe I should hide the tar in a function?
Apologies if the above is a FAQ, I've RTFM where M = "Learning the Korn
Shell" and "Unix Power Tools", I'm none the wiser (though opening the
latter is always good for a half hour off-topic diversion).
- Previous message: Doug Freyburger: "Re: filesystem or rawdevice"
- Next in thread: Stephane CHAZELAS: "Re: ksh script, exit status and pipe"
- Reply: Stephane CHAZELAS: "Re: ksh script, exit status and pipe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|