From 9471f292bb4369233b308f25209ea210e0e73ec5 Mon Sep 17 00:00:00 2001 From: carlfriedrich Date: Fri, 14 Oct 2022 14:41:01 +0200 Subject: [PATCH] zsh plugin: use standardized $0 handling See https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#zero-handling --- forgit.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 10e9828..4c81c7d 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -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