Skip to content

Commit

Permalink
bash.bash: eval-capture: fix regression from 3f47d47
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 2, 2025
1 parent 3f47d47 commit d377355
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sources/bash.bash
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function eval_capture {
# __print_lines "PRE: [$EVAL_CAPTURE_STATUS] cmd=[$EVAL_CAPTURE_COMMAND] subshell=[$EVAL_CAPTURE_SUBSHELL] context=[$EVAL_CAPTURE_CONTEXT]" >/dev/tty
EVAL_CAPTURE_COUNT="$((EVAL_CAPTURE_COUNT + 1))"
# wrap if the $- check, as always returning causes +e to return when it shouldn't
trap 'EVAL_CAPTURE_RETURN=$?; if [[ $- = *e* ]]; then eval_capture_wrapper_trap "$EVAL_CAPTURE_RETURN" "${FUNCNAME-}" "${cmd[*]}" "${BASH_SUBSHELL-}" "$EVAL_CAPTURE_CONTEXT"; return; fi' ERR
trap 'EVAL_CAPTURE_RETURN=$?; if [[ $- = *e* ]]; then eval_capture_wrapper_trap "$EVAL_CAPTURE_RETURN" "${FUNCNAME-}" "${cmd[*]}" "${BASH_SUBSHELL-}" "$EVAL_CAPTURE_CONTEXT"; return $?; fi' ERR # the [$?] in [return $?] is necessary: https://github.com/bevry/dorothy/actions/runs/13102792036
# can't delegate this to a function (e.g. is_subshell_function), as the trap will go to the function
if [[ $IS_BASH_VERSION_OUTDATED == 'yes' && $- == *e* && "$(declare -f "${cmd[0]}")" == "${cmd[0]}"$' () \n{ \n ('* ]]; then
# ALL SUBSHELLS SHOULD RE-ENABLE [set -e]
Expand Down

0 comments on commit d377355

Please sign in to comment.