URL: <https://savannah.gnu.org/support/?111211>
Summary: `pipefail` leak/disablement Group: The GNU Bourne-Again SHell Submitter: None Submitted: Mon 24 Mar 2025 07:47:14 AM UTC Category: None Priority: 5 - Normal Severity: 3 - Normal Status: None Privacy: Private Assigned to: None Originator Email: wod...@gmail.com Open/Closed: Open Discussion Lock: Any Operating System: GNU/Linux _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Mon 24 Mar 2025 07:47:14 AM UTC By: Anonymous = empty.sh = #!/usr/bin/bash set -x echo '---' &>/dev/null echo empty echo '---' &>/dev/null set +x if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then exit 0 else return 0 fi = menus.sh = #!/usr/bin/bash set -x echo '---' &>/dev/null echo menu echo '---' &>/dev/null set +x if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then exit 0 else return 0 fi = test_modules.sh = #!/usr/bin/bash set -o errexit set -o nounset set -o pipefail set -o xtrace export SHELLOPTS 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 pipefail_on=1 fi source "$1" # Restore flags [[ $saved_opts == *e* ]] && set -o errexit || set +o errexit [[ $saved_opts == *u* ]] && set -o nounset || set +o nounset [[ $saved_opts == *x* ]] && set -o xtrace || set +o xtrace # Restore pipefail if [[ $pipefail_on -eq 1 ]]; then set -o pipefail else set +o pipefail fi } bash -c 'set -o errexit -o nounset -o pipefail; bash -x './menus.sh' >'./exec_menus.sh.log' 2>&1' function source_menus() { echo "Before source: \$-=$-, SHELLOPTS=$SHELLOPTS" safe_source './menus.sh' echo "After source: \$-=$-, SHELLOPTS=$SHELLOPTS" } source_menus >'./src_menus.sh.log' 2>&1 bash -c 'set -o errexit -o nounset -o pipefail; bash -x './empty.sh' >'./exec_empty.sh.log' 2>&1' function source_empty() { echo "Before source: \$-=$-, SHELLOPTS=$SHELLOPTS" safe_source './empty.sh' echo "After source: \$-=$-, SHELLOPTS=$SHELLOPTS" } source_empty >'./src_empty.sh.log' 2>&1 exit 0 = src_menus.sh.log = + echo 'Before source: $-=ehuxB, SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:nounset:pipefail:xtrace' Before source: $-=ehuxB, SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:nounset:pipefail:xtrace + safe_source ./menus.sh + local saved_opts=ehuxB + local pipefail_on=0 + set -o + grep -q 'pipefail *on' + source ./menus.sh ++ set -x ++ echo --- ++ echo menu menu ++ echo --- ++ set +x + [[ 0 -eq 1 ]] + set +o pipefail + echo 'After source: $-=ehuxB, SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:nounset:xtrace' After source: $-=ehuxB, SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:nounset:xtrace _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/support/?111211> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature