Really old sh -- pipefail
Richard Laager
rlaager at wiktel.com
Thu Sep 10 02:30:27 UTC 2026
On 2026-09-09 17:13, Hal Murray wrote:
>
>> I just tested in dash, which is a minimal sh that does not support
>> pipefail. That code works as written and does not work without the ().
>
> Thanks. What do you mean by "does not work"?
dash immediately dies.
$ cat test1.dash
if set -o pipefail 2>/dev/null
then
echo PIPEFAIL supported
else
echo PIPEFAIL not supported
fi
echo HERE
$ dash test1.dash
$ cat test2.dash
if (set -o pipefail) 2>/dev/null
then
echo PIPEFAIL supported
else
echo PIPEFAIL not supported
fi
echo HERE
$ dash test2.dash
PIPEFAIL not supported
HERE
$
Note that "dash test1.dash" did not echo "HERE".
> As I see it, there are 2 cases: either the sh supports pipefail or it
> doesn't.
>
> If it does support pipefail then a simple "set -o pipefail" works as
> expected.
> If it doesn't support pipefail, then that gets an error message and
> pipefail doesn't get turned on.
and the shell dies:
$ cat test.dash
set -o pipefail
echo HERE
$ dash test.dash
test.dash: 1: set: Illegal option -o pipefail
--
Richard
More information about the devel
mailing list