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

$ true | false | true | false; echo [EMAIL PROTECTED]
0 1 0 1
$ { true | false | true | false; }; echo [EMAIL PROTECTED]
0 1 0 1

However, using parenthesis you launch the whole pipeline in a subshell
so it won't work:

$ ( true | false | true | false; ); echo [EMAIL PROTECTED]
1

Also, it mysteriously seems to be lost after every command in
interactive mode:

$ true | false | true | false
$ echo [EMAIL PROTECTED]
0

Although it does work in non-interactive mode:

$ echo $'true | false | true | false\necho [EMAIL PROTECTED]' | sh
0 1 0 1

If you want a less fragile approach, Oded Arbel gave a good advice.

-- 
Beni Cherniavsky <[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