help-bash
[Top][All Lists]
Advanced

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

[Help-bash] behavior of -o pipefail


From: Christof Warlich
Subject: [Help-bash] behavior of -o pipefail
Date: Sun, 28 Oct 2018 10:39:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi,

I'm a bit surprised w.r.t. the implemented (and documented) behavior of -o pipefail:

Why is the last instead of the first error code in a pipe returned? Example:

$ bash -o pipefail -c '(exit 42) | (exit 43) | (exit 0)'; echo $?
43

IMHO, returning the first error code (i.e. 42 in the previous example) would be much more intuitive and useful, as errors in subsequent pipeline steps are most likely just only due to errors in previous steps. But maybe I'm missing an important point and there is (and / or was) a good reason that matters are as they are?

Cheers,

Chris

P.S.: I know that the address@hidden allows compehensive access to all exit codes of a pipe, so admittedly, my question may only be considered as a matter of aesthetics.




reply via email to

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