bug-bash
[Top][All Lists]
Advanced

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

Re: [sr #111211] `pipefail` leak/disablement


From: Martin D Kealey
Subject: Re: [sr #111211] `pipefail` leak/disablement
Date: Tue, 25 Mar 2025 00:02:50 +1000

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


reply via email to

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