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

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