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:
fallwith 2019-03-20 11:49:04 -07:00
parent f8d843926a
commit 2743bcb7f7

View File

@ -1,5 +1,9 @@
#!/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="$_"
if [[ "$_under" == *".sh" ]]; then
current_script_path="$_under"