From bb37267ff81adcd2e9723d51e064b8462947aed8 Mon Sep 17 00:00:00 2001 From: Matthew Mazzola Date: Thu, 16 May 2024 13:19:50 -0700 Subject: [PATCH] Update shell scripts to support Zsh, not only Bash --- docker/cluster/run_singularity.sh | 8 +++++++- docker/container.sh | 8 +++++++- orbit.sh | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docker/cluster/run_singularity.sh b/docker/cluster/run_singularity.sh index b19688e9e9..a270ae5c1f 100755 --- a/docker/cluster/run_singularity.sh +++ b/docker/cluster/run_singularity.sh @@ -31,7 +31,13 @@ setup_directories() { # get script directory -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [ -n "$BASH_VERSION" ]; then + # Bash + SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +else + # Fallback for other shells + SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +fi # load variables to set the orbit path on the cluster source $SCRIPT_DIR/../.env.base diff --git a/docker/container.sh b/docker/container.sh index 865d06be6f..c5513b1aec 100755 --- a/docker/container.sh +++ b/docker/container.sh @@ -11,7 +11,13 @@ set -e tabs 4 # get script directory -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +if [ -n "$BASH_VERSION" ]; then + # Bash + SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +else + # Fallback for other shells + SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +fi STATEFILE="${SCRIPT_DIR}/.container.yaml" diff --git a/orbit.sh b/orbit.sh index 70505456c7..85cc878056 100755 --- a/orbit.sh +++ b/orbit.sh @@ -16,7 +16,13 @@ set -e tabs 4 # get source directory -export ORBIT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +if [ -n "$BASH_VERSION" ]; then + # Bash + SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +else + # Fallback for other shells + SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +fi #== # Helper functions