diff --git a/scripts/hooks.sh b/scripts/hooks.sh index 845ead9..2ed626e 100644 --- a/scripts/hooks.sh +++ b/scripts/hooks.sh @@ -42,10 +42,10 @@ __resh_collect() { #__RESH_GIT_TOPLEVEL="$(git rev-parse --show-toplevel)" #__RESH_GIT_TOPLEVEL_EXIT_CODE=$? - if [ -n "$ZSH_VERSION" ]; then + if [ -n "${ZSH_VERSION-}" ]; then # assume Zsh local __RESH_PID="$$" # current pid - elif [ -n "$BASH_VERSION" ]; then + elif [ -n "${BASH_VERSION-}" ]; then # assume Bash if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then # $BASHPID is only available in bash4+ diff --git a/scripts/util.sh b/scripts/util.sh index 037ff22..0694f99 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -9,7 +9,13 @@ __resh_get_pid() { local __RESH_PID="$$" # current pid elif [ -n "${BASH_VERSION-}" ]; then # assume Bash - local __RESH_PID="$BASHPID" # current pid + if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then + # $BASHPID is only available in bash4+ + # $$ is fairly similar so it should not be an issue + local __RESH_PID="$BASHPID" # current pid + else + local __RESH_PID="$$" # current pid + fi fi echo "$__RESH_PID" }