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"