Blame SOURCES/bz1903677-ocf-shellfuncs-fix-traceback-redirection-bash5.patch

4a94c3
From 908431d416076e3ceb70cc95871957d15265a949 Mon Sep 17 00:00:00 2001
4a94c3
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4a94c3
Date: Wed, 2 Dec 2020 16:48:32 +0100
4a94c3
Subject: [PATCH] ocf-shellfuncs: make ocf_is_bash4() detect Bash v4 or greater
4a94c3
 (which it was supposed to according to the comments)
4a94c3
4a94c3
---
4a94c3
 heartbeat/ocf-shellfuncs.in | 13 +++++++++----
4a94c3
 1 file changed, 9 insertions(+), 4 deletions(-)
4a94c3
4a94c3
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
4a94c3
index b8d47e3d5..ac75dfc87 100644
4a94c3
--- a/heartbeat/ocf-shellfuncs.in
4a94c3
+++ b/heartbeat/ocf-shellfuncs.in
4a94c3
@@ -907,13 +907,18 @@ ocf_unique_rundir()
4a94c3
 # NB: FD 9 may be used for tracing with bash >= v4 in case
4a94c3
 # OCF_TRACE_FILE is set to a path.
4a94c3
 #
4a94c3
-ocf_is_bash4() {
4a94c3
+ocf_bash_has_xtracefd() {
4a94c3
 	echo "$SHELL" | grep bash > /dev/null &&
4a94c3
-			[ ${BASH_VERSINFO[0]} = "4" ]
4a94c3
+			[ ${BASH_VERSINFO[0]} -ge 4 ]
4a94c3
+}
4a94c3
+# for backwards compatibility
4a94c3
+ocf_is_bash4() {
4a94c3
+	ocf_bash_has_xtracefd
4a94c3
+	return $?
4a94c3
 }
4a94c3
 ocf_trace_redirect_to_file() {
4a94c3
 	local dest=$1
4a94c3
-	if ocf_is_bash4; then
4a94c3
+	if ocf_bash_has_xtracefd; then
4a94c3
 		exec 9>$dest
4a94c3
 		BASH_XTRACEFD=9
4a94c3
 	else
4a94c3
@@ -922,7 +927,7 @@ ocf_trace_redirect_to_file() {
4a94c3
 }
4a94c3
 ocf_trace_redirect_to_fd() {
4a94c3
 	local fd=$1
4a94c3
-	if ocf_is_bash4; then
4a94c3
+	if ocf_bash_has_xtracefd; then
4a94c3
 		BASH_XTRACEFD=$fd
4a94c3
 	else
4a94c3
 		exec 2>&$fd