Merge pull request #891 from ucb-bar/unfuck-zsh-yet-again

Use a ZSH-compatible version of BASH_SOURCE[0]
This commit is contained in:
alonamid
2021-06-12 12:31:26 -07:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -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() {

View File

@@ -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"