Skip to content

Commit

Permalink
estack.eclass: Use 'shopt -p -o' to restore 'set' flags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgorny committed Apr 14, 2017
1 parent 16112d6 commit 16c504f
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions eclass/estack.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 16c504f

Please sign in to comment.