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.
> $ true | false | true | false; echo [EMAIL PROTECTED]
> 0 10 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
>
Works for me:
shlomi:~$ true | false | false | true
shlomi:~$ echo [EMAIL PROTECTED]
0 1 1 0
Maybe you execute some command after every prompt.
> Although it does work in non-interactive mode:
>
> $ echo $'true | false | true | false\necho [EMAIL PROTECTED]' | sh
> 0 1 0 1
>
Wow, I wasn't aware of the $'' construct. I guess you learn something new
every day. :-)
> If you want a less fragile approach, Oded Arbel gave a good advice.
>
This approach is also dependent on the user shell being bash. I am using
this shell call from a Perl script. In any case, I eliminated the pipeline
from the command and now this is no longer relevant.
Thanks anyway.
Regards,
Shlomi Fish
----------------------------------------------------------------------
Shlomi Fish [EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/
Writing a BitKeeper replacement is probably easier at this point than getting
its license changed.
Matt Mackall on OFTC.net #offtopic.
=================================================================
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]