[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
extdebug now implies errtrace which implies `trap ... ERR` execution w/o
From: |
Mike Frysinger |
Subject: |
extdebug now implies errtrace which implies `trap ... ERR` execution w/out `set -e` |
Date: |
Mon, 8 Feb 2021 23:54:52 -0500 |
this set of changes between bash-4.3 & bash-4.4:
https://git.savannah.gnu.org/cgit/bash.git/commit/?h=814e1ff513ceca5d535b92f6c8dd9af7554fe83e
has this buried nugget:
+ - shopt_set_debug_mode: make sure error_trace_mode reflects the setting
+ of extdebug. This one is tentative. Fix from Grisha Levit
+ <grishalevit@gmail.com>
+ - shopt_set_debug_mode: call set_shellopts after setting
error_trace_mode
+ or function_trace_mode. Fix from Grisha Levit <grishalevit@gmail.com>
which i'm guessing means this behavior is intentional:
$ bash-4.3 -c 'shopt -p -o | grep err; shopt -s extdebug; shopt -p -o | grep
err'
set +o errexit
set +o errtrace
set +o errexit
set +o errtrace
$ bash-4.4 -c 'shopt -p -o | grep err; shopt -s extdebug; shopt -p -o | grep
err'
set +o errexit
set +o errtrace
set +o errexit
set -o errtrace
we're in the process of upgrading from bash-4.3 to bash-4.4 and it broke
our build scripts because we use `trap ... ERR` with `shopt -s extdebug`,
but we also toggle `set +e` in a few places to avoid trapping. that is
no longer sufficient, and now we have to do `set +eE` and `set -eE`.
example shell script showing change in behavior:
$ cat test.sh
#!/bin/bash
foo() {
false
return 0
}
shopt -s extdebug
trap 'echo invalid trap; exit 1' ERR
foo
echo "pass"
$ bash-4.3 ./test.sh
pass
$ bash-4.4 ./test.sh
invalid trap
the manual text for extdebug didn't change between the versions, so it's
not clear if this is overall intended as a bug fix.
-mike
- extdebug now implies errtrace which implies `trap ... ERR` execution w/out `set -e`,
Mike Frysinger <=