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