On Fri, Oct 24, 2003 at 10:47:22PM +0200, Oleg Goldshmidt wrote:
> Shlomi Fish <[EMAIL PROTECTED]> writes:
> 
> > On Fri, 24 Oct 2003, Beni Cherniavsky wrote:
> > 
> > > Shlomi Fish wrote on 2003-10-12:
> > >
> > > > I want that if one of the (first) components of the pipeline exits with an
> > > > error code, I'll know about it somehow. How?
> > > >
> > > info bash --index PIPESTATUS
> > >
> > 
> > Cool thanks.
> 
> Depending on your needs you may also use the -e option to the shell
> (should work for most Bourne shell and csh descendants), the option
> will make the shell exit if any of the commands in the pipeline fails.
> 
> $ true | false | true
> $ echo $?
> 0
> $ bash -e "true | false | true"
> true | false | true: true | false | true: No such file or directory
> $ echo $?
> 1

This is because you tried running a script from a file called
"true | false | true"

However:

$ set -e
$ true | false | true
$ echo $?
0

So setting that doesn't make an error from the middle of a pipe show.

-- 
Tzafrir Cohen                       +---------------------------+
http://www.technion.ac.il/~tzafrir/ |vim is a mutt's best friend|
mailto:[EMAIL PROTECTED]       +---------------------------+

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to