Skip to content

Commit c29730c

Browse files
authored
Merge pull request #11 from glennj/setting-dir-is-shell-specific
Finding the directory of the xr.sh script is shell-specific. Fixes #10.
2 parents 99a9e95 + 6305ae3 commit c29730c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

xr.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
# Constants.
44
_exo_config=".exercism/metadata.json"
5-
_dir="$(dirname "$(readlink -f "$0")")"
5+
6+
# Finding the location of the sourced script is shell-specific
7+
# Currently, zsh and bash are the only supported shells
8+
if [ -n "$ZSH_VERSION" ]; then
9+
_dir="$(dirname "$(readlink -f "$0")")"
10+
elif [ -n "$BASH_VERSION" ]; then
11+
_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
12+
else
13+
echo "This is an unsupported shell." >&2
14+
return 1
15+
fi
616

717
read -r -d '' _short_doc << EOF
818
Usage: xr [<command>] [<uuid>]

0 commit comments

Comments
 (0)