mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: set default shell version values on POSIX entrypoint (#1594)
Co-authored-by: James Hegedus <jthegedus@hey.com>
This commit is contained in:
parent
2043a09574
commit
4d5f22ddb8
10
asdf.sh
10
asdf.sh
@ -8,7 +8,7 @@
|
|||||||
export ASDF_DIR="${ASDF_DIR:-}"
|
export ASDF_DIR="${ASDF_DIR:-}"
|
||||||
|
|
||||||
if [ -z "$ASDF_DIR" ]; then
|
if [ -z "$ASDF_DIR" ]; then
|
||||||
if [ -n "$BASH_VERSION" ]; then
|
if [ -n "${BASH_VERSION:-}" ]; then
|
||||||
# Use BASH_SOURCE[0] to obtain the relative path to this source'd file. Since it's
|
# Use BASH_SOURCE[0] to obtain the relative path to this source'd file. Since it's
|
||||||
# a relative path, 'cd' to its dirname and use '$PWD' to obtain the fullpath.
|
# a relative path, 'cd' to its dirname and use '$PWD' to obtain the fullpath.
|
||||||
# Use 'builtin cd' to ensure user-defined 'cd()' functions aren't called.
|
# Use 'builtin cd' to ensure user-defined 'cd()' functions aren't called.
|
||||||
@ -28,14 +28,14 @@ if [ -z "$ASDF_DIR" ]; then
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
unset -v _asdf_old_dir
|
unset -v _asdf_old_dir
|
||||||
elif [ -n "$ZSH_VERSION" ]; then
|
elif [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
# Use '%x' to expand to path of current file. It must be prefixed
|
# Use '%x' to expand to path of current file. It must be prefixed
|
||||||
# with '(%):-', so it expands in non-prompt-string contexts.
|
# with '(%):-', so it expands in non-prompt-string contexts.
|
||||||
|
|
||||||
# shellcheck disable=SC2296
|
# shellcheck disable=SC2296
|
||||||
ASDF_DIR=${(%):-%x}
|
ASDF_DIR=${(%):-%x}
|
||||||
ASDF_DIR=${ASDF_DIR%/*}
|
ASDF_DIR=${ASDF_DIR%/*}
|
||||||
elif [ -n "$KSH_VERSION" ] && [ -z "$PATHSEP" ]; then
|
elif [ -n "${KSH_VERSION:-}" ] && [ -z "$PATHSEP" ]; then
|
||||||
# Only the original KornShell (kornshell.com) has a '.sh.file' variable with the path
|
# Only the original KornShell (kornshell.com) has a '.sh.file' variable with the path
|
||||||
# of the current file. To prevent errors with other variations, such as the MirBSD
|
# of the current file. To prevent errors with other variations, such as the MirBSD
|
||||||
# Korn shell (mksh), test for 'PATHSEP' which is _not_ set on the original Korn Shell.
|
# Korn shell (mksh), test for 'PATHSEP' which is _not_ set on the original Korn Shell.
|
||||||
@ -65,7 +65,7 @@ if [ -n "${ASDF_FORCE_PREPEND+x}" ]; then
|
|||||||
else
|
else
|
||||||
# If ASDF_FORCE_PREPEND is not set, then prepend by default on macOS
|
# If ASDF_FORCE_PREPEND is not set, then prepend by default on macOS
|
||||||
# to workaround `path_helper`.
|
# to workaround `path_helper`.
|
||||||
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
|
if [ -n "${BASH_VERSION:-}" ] || [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
# shellcheck disable=SC3028
|
# shellcheck disable=SC3028
|
||||||
case $OSTYPE in
|
case $OSTYPE in
|
||||||
darwin*) _asdf_should_prepend=yes ;;
|
darwin*) _asdf_should_prepend=yes ;;
|
||||||
@ -85,7 +85,7 @@ fi
|
|||||||
# If prepending is enabled, remove any existing instances of asdf from PATH so
|
# If prepending is enabled, remove any existing instances of asdf from PATH so
|
||||||
# the prepending done after is always at the frontmost part of the PATH.
|
# the prepending done after is always at the frontmost part of the PATH.
|
||||||
if [ "$_asdf_should_prepend" = 'yes' ]; then
|
if [ "$_asdf_should_prepend" = 'yes' ]; then
|
||||||
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
|
if [ -n "${BASH_VERSION:-}" ] || [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
# shellcheck disable=SC3060
|
# shellcheck disable=SC3060
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*":${_asdf_bin}:"*) PATH=${PATH//$_asdf_bin:/} ;;
|
*":${_asdf_bin}:"*) PATH=${PATH//$_asdf_bin:/} ;;
|
||||||
|
Loading…
Reference in New Issue
Block a user