Blame SOURCES/BZ-1927971-let-scl_source-behave-with-errexit.patch

7c2825
From a8113846229a567321ca4347b07263936307b940 Mon Sep 17 00:00:00 2001
7c2825
From: "James E. Flemer" <james.flemer@ndpgroup.com>
7c2825
Date: Tue, 16 Feb 2021 02:48:27 -0700
7c2825
Subject: [PATCH] Let scl_source behave when "-e"/errexit is set (#35)
7c2825
7c2825
Jenkins pipelines, among other things, use `set -e` (aka bash `errexit`) to abort on "errors". So when `source scl_source` is used in a pipeline, the way the exit code from `scl_enabled` is checked via `$?` causes an unintended abort of the pipeline. (Workaround is to use `set +e; source scl_source ...; set -e`.)
7c2825
7c2825
This trivial change to `scl_source` simply changes how the value of `scl_enalbed` is checked to be friendly to `errexit`.
7c2825
---
7c2825
 shell/scl_source | 3 +--
7c2825
 1 file changed, 1 insertion(+), 2 deletions(-)
7c2825
7c2825
diff --git a/shell/scl_source b/shell/scl_source
7c2825
index 5822955..30b8baf 100755
7c2825
--- a/shell/scl_source
7c2825
+++ b/shell/scl_source
7c2825
@@ -47,8 +47,7 @@ for arg in "$@"; do
7c2825
     done
7c2825
 
7c2825
     # Now check if the collection isn't already enabled
7c2825
-    /usr/bin/scl_enabled $arg > /dev/null 2> /dev/null
7c2825
-    if [ $? -ne 0 ]; then
7c2825
+    if ! /usr/bin/scl_enabled $arg > /dev/null 2> /dev/null; then
7c2825
         _scls+=($arg)
7c2825
         _scl_prefixes+=($_scl_prefix)
7c2825
     fi;
7c2825
-- 
7c2825
2.29.2
7c2825