Skip to content

Commit

Permalink
Use a ZSH-compatible version of BASH_SOURCE[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbiancolin committed Jun 11, 2021
1 parent b59ff89 commit e196540
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scripts/build-toolchains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion scripts/init-submodules-no-riscv-tools-nolog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e196540

Please sign in to comment.