From e1965400f6d1cbd49df49791fb078c967713ba6a Mon Sep 17 00:00:00 2001 From: David Biancolin Date: Fri, 11 Jun 2021 04:58:33 +0000 Subject: [PATCH] Use a ZSH-compatible version of BASH_SOURCE[0] --- scripts/build-toolchains.sh | 4 +++- scripts/init-submodules-no-riscv-tools-nolog.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/build-toolchains.sh b/scripts/build-toolchains.sh index 611f50e01a..19fa524e44 100755 --- a/scripts/build-toolchains.sh +++ b/scripts/build-toolchains.sh @@ -6,7 +6,9 @@ set -e set -o pipefail -DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +# If BASH_SOURCE is undefined, we may be running under zsh, in that case +# provide a zsh-compatible alternative +DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" CHIPYARD_DIR="$(dirname "$DIR")" usage() { diff --git a/scripts/init-submodules-no-riscv-tools-nolog.sh b/scripts/init-submodules-no-riscv-tools-nolog.sh index 0039d9df15..2d2e920cef 100755 --- a/scripts/init-submodules-no-riscv-tools-nolog.sh +++ b/scripts/init-submodules-no-riscv-tools-nolog.sh @@ -17,7 +17,9 @@ if [ "$MINGIT" != "$(echo -e "$MINGIT\n$MYGIT" | sort -V | head -n1)" ]; then false fi -DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +# If BASH_SOURCE is undefined we may be running under zsh, in that case +# provide a zsh-compatible alternative +DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]:-${(%):-%x}}")")" CHIPYARD_DIR="$(dirname "$DIR")" cd "$CHIPYARD_DIR"