*.sh: Fix some shellcheck issues

This commit is contained in:
2025-06-27 12:59:13 +02:00
parent 3eb9113546
commit 5078b6a63f
7 changed files with 16 additions and 15 deletions

View File

@@ -6,20 +6,22 @@
# correct directory.
if [ $# -eq 0 ]; then
printf >&2 "Usage: $(basename "$0") <function>\n"
printf >&2 "Usage: %s <function>\n" "$(basename "$0")"
exit 1
fi
name="$1"
shift
BASE="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git"
# In git aliases, shell commands are executed from the top-level directory of
# the repo. GIT_PREFIX contains the original directory relative to the
# top-level.
[ -z "$GIT_PREFIX" ] || cd "$GIT_PREFIX"
[ -z "$GIT_PREFIX" ] || cd "$GIT_PREFIX" || exit
# no need for error handling, the message from sh is descriptive enough
if [ "${1#git-}" != "$1" ] || [ -e "$BASE/$1" ]; then
exec "$BASE/$@"
if [ "${name#git-}" != "$name" ] || [ -e "$BASE/$name" ]; then
exec "$BASE/$name" "$@"
else
exec "$BASE/git-$@"
exec "$BASE/git-$name" "$@"
fi