public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] estack.eclass: Properly restore shopt options.
@ 2019-11-23 10:18 Ulrich Müller
  2019-11-23 11:28 ` [gentoo-dev] [PATCH] estack.eclass: Drop isdigit function Ulrich Müller
  0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Müller @ 2019-11-23 10:18 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]

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, by which restoring the noglob
option 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@gentoo.org>
---
 eclass/estack.eclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/estack.eclass b/eclass/estack.eclass
index f548abf8c283..b0177bdb358e 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
-- 
2.24.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-dev] [PATCH] estack.eclass: Drop isdigit function.
  2019-11-23 10:18 [gentoo-dev] [PATCH] estack.eclass: Properly restore shopt options Ulrich Müller
@ 2019-11-23 11:28 ` Ulrich Müller
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Müller @ 2019-11-23 11:28 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

It isn't (and never was) used by anything else in the tree. Inline its
only usage in evar_pop() and drop the function.
---
 eclass/estack.eclass | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/eclass/estack.eclass b/eclass/estack.eclass
index b0177bdb358e..2aa6f366dc12 100644
--- a/eclass/estack.eclass
+++ b/eclass/estack.eclass
@@ -115,7 +115,8 @@ evar_pop() {
 	local cnt=${1:-bad}
 	case $# in
 	0) cnt=1 ;;
-	1) isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*" ;;
+	1) [[ -z ${cnt//[0-9]} ]] \
+		|| die "${FUNCNAME}: first arg must be a number: $*" ;;
 	*) die "${FUNCNAME}: only accepts one arg: $*" ;;
 	esac
 
@@ -197,17 +198,5 @@ eumask_pop() {
 	umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
 }
 
-# @FUNCTION: isdigit
-# @USAGE: <number> [more numbers]
-# @DESCRIPTION:
-# Return true if all arguments are numbers.
-isdigit() {
-	local d
-	for d ; do
-		[[ ${d:-bad} == *[!0-9]* ]] && return 1
-	done
-	return 0
-}
-
 _ESTACK_ECLASS=1
 fi #_ESTACK_ECLASS
-- 
2.24.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-23 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-23 10:18 [gentoo-dev] [PATCH] estack.eclass: Properly restore shopt options Ulrich Müller
2019-11-23 11:28 ` [gentoo-dev] [PATCH] estack.eclass: Drop isdigit function Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox