bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: different exit codes in $? and ${PIPESTATUS[@]}


From: Wladimir Sidorenko
Subject: Re: different exit codes in $? and ${PIPESTATUS[@]}
Date: Sun, 14 Oct 2012 11:46:17 +0300

> What do you think should happen in the following case?
> ! exit 1 | exit 2 | exit 3

To my mind the '!' operator should have had a higher precedence during
parsing command line arguments than the pipe and applied only to the
command it was immediately preceding. So that in

! command1 | command2 | command3

it would only negate command1. If one wanted to negate the final exit
code of the whole pipe something like

! { command1 | command2 | command3; }

could be used. To my mind '!' looks pretty much like a unary operator
and '|' like a binary one.
 And in many programming languages unary operators usually have a
higher precedence than binary.

> Why should $PIPESTATUS not reflect the actual exit statuses?

It of course should. But the question was what is the actual or
expected exit status in

! test 0 -eq 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]