zsh plugin: use standardized $0 handling

See https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#zero-handling
This commit is contained in:
carlfriedrich 2022-10-14 14:41:01 +02:00
parent 4995c614e4
commit 9471f292bb

View file

@ -5,7 +5,11 @@ forgit::warn() { printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$@" >&2; }
# set installation path
if [[ -n "$ZSH_VERSION" ]]; then
FORGIT_INSTALL_DIR="$( dirname -- "$0")"
# shellcheck disable=2277,2296,2299
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
# shellcheck disable=2277,2296,2298
0="${${(M)0:#/*}:-$PWD/$0}"
FORGIT_INSTALL_DIR="${0:h}"
elif [[ -n "$BASH_VERSION" ]]; then
FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
else