mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
asdf.sh: comments for script path determination
Update `asdf.sh` to explain that `$_`, `${BASH_SOURCE[0]}`, and `$0` are used by Korn, Bash, and Zsh (and others) to obtain the path to the script, and what those special variables mean.
This commit is contained in:
parent
f8d843926a
commit
2743bcb7f7
4
asdf.sh
4
asdf.sh
@ -1,5 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# For Korn shells (ksh, mksh, etc.), capture $_ (the final parameter passed to
|
||||||
|
# the last command) straightaway, as it will contain the path to this script.
|
||||||
|
# For Bash, ${BASH_SOURCE[0]} will be used to obtain this script's path.
|
||||||
|
# For Zsh and others, $0 (the path to the shell or script) will be used.
|
||||||
_under="$_"
|
_under="$_"
|
||||||
if [[ "$_under" == *".sh" ]]; then
|
if [[ "$_under" == *".sh" ]]; then
|
||||||
current_script_path="$_under"
|
current_script_path="$_under"
|
||||||
|
Loading…
Reference in New Issue
Block a user