It seems that we can try to enable the pipefail option opportunistically by utilizing the || (logical OR expression) to avoid failing the whole script if the option is not defined for a given shell.
Also, nowadays most shells seems to support pipefail, for example, on OpenBSD, the /bin/sh is actually /bin/ksh:
This version of sh is actually ksh in disguise. As such, it also supports the features described in ksh(1).
I've created the following script instruction to run on FreeBSD:
And it was marked as succeed, but in reality, it failed because
wget
was not installed:This seems to be happening because the
pipefail
option is only set on when using Bash:https://github.com/cirruslabs/cirrus-ci-agent/blob/445a87400c7f080f7bc7a142b76284d47ae61afe/internal/executor/cmd.go#L44-L46
It seems that we can try to enable the
pipefail
option opportunistically by utilizing the||
(logical OR expression) to avoid failing the whole script if the option is not defined for a given shell.Also, nowadays most shells seems to support
pipefail
, for example, on OpenBSD, the/bin/sh
is actually/bin/ksh
:...and
ksh(1)
supportspipefail
.On FreeBSD,
/bin/sh
supportspipefail
option natively.ZSH seems to support
pipefail
too, at least on macOS: