commit:     dc3e0c5e828b87f8af2542ff29d3d80bda37fdbd
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 22 18:28:50 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 07:37:30 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc3e0c5e

90gcc-warnings: simplify xtrace option handling

Simplify the xtrace handling by stashing a command that restores the
option's present status before unconditionally disabling it.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/install-qa-check.d/90gcc-warnings | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index ea51f19d32..4da17b154b 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -3,17 +3,14 @@
 # TODO: add -Wformat-security
 
 gcc_warn_check() {
-        local abort f grep_cmd joined_msgs reset_debug
+        local abort f grep_cmd joined_msgs reset_xtrace
         local -a msgs
 
        # Evaluate misc gcc warnings
        # In debug mode, this variable definition and corresponding grep calls
        # will produce false positives if they're shown in the trace.
-       reset_debug=0
-       if [[ $- == *x* ]] ; then
-               set +x
-               reset_debug=1
-       fi
+       reset_xtrace=$(shopt -o -p xtrace)
+       shopt -o -u xtrace
 
        msgs=(
                # only will and does, no might :)
@@ -172,7 +169,7 @@ gcc_warn_check() {
                __vecho -ne '\n'
        fi
 
-       [[ ${reset_debug} = 1 ]] && set -x
+       eval "${reset_xtrace}"
 
        if [[ ${abort} == "yes" ]] ; then
                echo "Please do not file a Gentoo bug and instead" \

Reply via email to