Really old sh -- pipefail
Richard Laager
rlaager at wiktel.com
Wed Sep 9 21:15:08 UTC 2026
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 ().
I believe the () spawns a subshell generally.
On 2026-09-09 06:16, Hal Murray via devel wrote:
>
> I'm trying to understand this code from tests/option-tester.sh
>
> # set pipefail to catch pipeline failures
> # Unfortunately, it doesn't work on some older sh-es
> if (set -o pipefail) 2>/dev/null
> then
> set -o pipefail
> fi
>
> What is the () doing there? Why not just set it and ignore the error if
> that doesn't work?
>
> I no longer have any systems that are old enough to have a sh that doesn't
> support pipefail.
>
> Does anybody have an old sh to experiment with?
>
>
--
Richard
More information about the devel
mailing list