function safe_source() {
> local saved_opts=$-
> local pipefail_on=0
>
> # Check if pipefail is set using 'shopt'
> if (set -o | grep -q 'pipefail *on'); then
>
'on' or 'off' is preceded by a tab character, plus arbitrary padding
spaces, so that won't work.
But it's a suboptimal approach to begin with.
To check a shell option such as pipefail, pick one of these:
[[ -o pipefail ]]
shopt -qo pipefail
[[ :$SHELLOPTS: = *:pipefail:* ]]
-Martin