Skip to content

Commit

Permalink
Remove a bashism in ocf-shellfuncs.in
Browse files Browse the repository at this point in the history
The function `ocf_bash_has_xtracefd` and its alias `ocf_is_bash4` break non bash shells (in my case dash) because of how bash version is tested. Due to local environment idiosyncrasies it is perfectly possible to have dash running a script while the variable `SHELL` has a value of `/bin/bash`. It works fine for most of the code except the tracing functionality.

What I propose is to fix the version detection mechanism by first checking against the usually not exported variable `BASH_VERSION`.
  • Loading branch information
tleguern authored Jul 22, 2021
1 parent 83cc15c commit 934da2f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions heartbeat/ocf-shellfuncs.in
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,11 @@ ocf_unique_rundir()
# OCF_TRACE_FILE is set to a path.
#
ocf_bash_has_xtracefd() {
echo "$SHELL" | grep bash > /dev/null &&
[ ${BASH_VERSINFO[0]} -ge 4 ]
[ -n "$BASH_VERSION" ] && [ ${BASH_VERSINFO[0]} -ge 4 ]
}
# for backwards compatibility
ocf_is_bash4() {
ocf_bash_has_xtracefd
return $?
}
ocf_trace_redirect_to_file() {
local dest=$1
Expand Down

0 comments on commit 934da2f

Please sign in to comment.