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