From d3b1b84d38decc7313d9f08f45aeeb7d8e1676ac Mon Sep 17 00:00:00 2001 From: Simon Let Date: Fri, 17 Jan 2020 17:20:07 +0100 Subject: [PATCH] fixes --- scripts/hooks.sh | 4 ++-- scripts/util.sh | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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" }