From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B391C139694 for ; Fri, 24 Mar 2017 21:03:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 79F1E21C1F8; Fri, 24 Mar 2017 21:02:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3114621C184 for ; Fri, 24 Mar 2017 21:02:09 +0000 (UTC) Received: from localhost.localdomain (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 45859341665; Fri, 24 Mar 2017 21:02:07 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: base-system@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 2/2] estack.eclass: Use 'shopt -p -o' to restore 'set' flags Date: Fri, 24 Mar 2017 22:01:57 +0100 Message-Id: <20170324210157.27562-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170324210157.27562-1-mgorny@gentoo.org> References: <20170324210157.27562-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Archives-Salt: c4d70ed9-abb7-4e92-b167-ba2c375c345b X-Archives-Hash: 46fe033b32852027ce72c7ec505b0df6 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. --- eclass/estack.eclass | 9 ++------- 1 file 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 -- 2.12.1