commit:     d2cb9490dbee48a32f196d1aa80d7356a99d9fd8
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 23 10:18:18 2019 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Nov 26 19:23:19 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2cb9490

estack.eclass: Properly restore shopt options.

Calling "eshopts_push; eshopts_pop" makes Portage report a QA issue:
* QA Notice: Global shell options changed and were not restored while calling 
'src_prepare'

This is caused by some side effect in bash, by which disabling
the "posix" option (even if it was already disabled before) in a
non-interactive shell also disables the "expand_aliases" option.
Work around the problem by always saving and restoring both "set -o"
and "shopt" option sets.

Also fix "estack_push -s" which should not execute shopt when called
without further parameters.

Closes: https://bugs.gentoo.org/662586
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 eclass/estack.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/estack.eclass b/eclass/estack.eclass
index f548abf8c28..b0177bdb358 100644
--- a/eclass/estack.eclass
+++ b/eclass/estack.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: estack.eclass
@@ -153,12 +153,13 @@ evar_pop() {
 #              eshopts_pop
 # @CODE
 eshopts_push() {
+       # Save both "shopt" and "set -o" option sets, because otherwise
+       # restoring noglob would disable expand_aliases by side effect. #662586
+       estack_push eshopts "$(shopt -p -o) $(shopt -p)"
        if [[ $1 == -[su] ]] ; then
-               estack_push eshopts "$(shopt -p)"
-               [[ $# -eq 0 ]] && return 0
+               [[ $# -le 1 ]] && return 0
                shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
        else
-               estack_push eshopts "$(shopt -p -o)"
                [[ $# -eq 0 ]] && return 0
                set "$@" || die "${FUNCNAME}: bad options to set: $*"
        fi

Reply via email to