From d707bb187c920b74aecd5a5b1b71febbaa81e8ee Mon Sep 17 00:00:00 2001 From: typicode Date: Mon, 25 Sep 2023 22:33:11 +0200 Subject: [PATCH] perf: port enhancements from main --- husky.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/husky.sh b/husky.sh index 155bd1b8..282f7d89 100644 --- a/husky.sh +++ b/husky.sh @@ -13,12 +13,8 @@ exit_hook() { exit "$1" } -self="$( - cd "$(dirname "$0")" - pwd -P -)" -hook="$(basename "$0")" -script="$self/../$hook" +hook="${0##*/}" +script="${0%/*/*}/../$hook" debug "starting $hook..." @@ -31,15 +27,15 @@ if [ "$HUSKY" = "0" ] || [ ! -f "$script" ]; then exit 0 fi -for file in "$XDG_CONFIG_HOME/husky/init.sh" "$HOME/.config/husky/init.sh" "$HOME/.huskyrc"; do - if [ -f "$file" ]; then +for file in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc.sh"; + do if [ -f "$file" ]; then debug "sourcing $file" . "$file" break fi done -if [ "$(basename -- "$SHELL")" = "zsh" ] || [ "$(basename -- "$SHELL")" = "bash" ]; then +if [ "${SHELL##*/}" = "zsh" ]; then debug "running $script with $SHELL" "$SHELL" -e "$script" "$@" else