From c27bf72fee18ddbdcba9187fcdb09c62b1d531db Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 20 Jun 2025 12:29:19 +0200 Subject: [PATCH] zsh:diffcmds: Slight refactor & format adjustments --- .config/zsh/zshrc.d/40-functions.zsh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index df25595..b8daa9b 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -700,10 +700,10 @@ diffcmds() { # Quote special characters and split into arrays set -- "${(q@)@}" - template=("${@:1:$((i-1))}") + template=( "${@:1:$((i-1))}" ) args=("${@:$((i+1))}") # Unquote standalone pipes - template=("${(@)template/#%\\|/|}") + template=( "${(@)template/#%\\|/|}" ) # Place arguments at the back if no position was supplied with `%%` [[ "$template[@]" =~ '%%' ]] || template+='%%' @@ -727,16 +727,12 @@ diffcmds() { fi # NOTE: `=()` is necessary since vimdiff is seeking the file. See zshexpn(1) - [[ $diff_cmd = vimdiff ]] && ps_sub='=(' || ps_sub='<(' + [[ $diff_cmd = vimdiff ]] && ps_sub='=' || ps_sub='<' final_cmd=("$diff_cmd") for arg in "$args[@]"; do # Substitute placeholder and wrap in process substitution - final_cmd+=( - "$ps_sub" - "${(@)template//\%\%/$arg}" - ")" - ) + final_cmd+=( "$ps_sub(${(@)template//\%\%/$arg})" ) done eval "$final_cmd[@]" }