summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-03-24 21:58:34 +0100
committerMichał Górny <mgorny@gentoo.org>2017-04-14 18:27:52 +0200
commit16c504f37e471540d3835e7f2fe6beb1f133e29b (patch)
tree0614e59cfc3c979173071e3d46b50d3d06b53f00 /eclass/estack.eclass
parenteclass/tests/estack_eshopts.sh: Add tests for 'set' variant of eshopt* (diff)
downloadgentoo-16c504f37e471540d3835e7f2fe6beb1f133e29b.tar.gz
gentoo-16c504f37e471540d3835e7f2fe6beb1f133e29b.tar.bz2
gentoo-16c504f37e471540d3835e7f2fe6beb1f133e29b.zip
estack.eclass: Use 'shopt -p -o' to restore 'set' flags
Use 'shopt -p -o' to obtain the current set of 'set' flags, and to restore them on popping. Unlike $-, it is output in command form (alike 'shopt -p'), removing the need for separate logic in eshopts_pop.
Diffstat (limited to 'eclass/estack.eclass')
-rw-r--r--eclass/estack.eclass9
1 files changed, 2 insertions, 7 deletions
diff --git a/eclass/estack.eclass b/eclass/estack.eclass
index 19c388f3d8d2..f548abf8c283 100644
--- a/eclass/estack.eclass
+++ b/eclass/estack.eclass
@@ -158,7 +158,7 @@ eshopts_push() {
[[ $# -eq 0 ]] && return 0
shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
else
- estack_push eshopts $-
+ estack_push eshopts "$(shopt -p -o)"
[[ $# -eq 0 ]] && return 0
set "$@" || die "${FUNCNAME}: bad options to set: $*"
fi
@@ -172,12 +172,7 @@ eshopts_push() {
eshopts_pop() {
local s
estack_pop eshopts s || die "${FUNCNAME}: unbalanced push"
- if [[ ${s} == "shopt -"* ]] ; then
- eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
- else
- set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-"
- set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}"
- fi
+ eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
}
# @FUNCTION: eumask_push