From 52e5d1ab4d319bd8ef2daf7f5cf8d47a3added39 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sun, 24 Mar 2024 17:54:11 +0100 Subject: [PATCH] zsh:diffcmds: Do the quotation only once --- .config/zsh/zshrc.d/40-functions.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index e59bb03..511517f 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -691,11 +691,12 @@ diffcmds() { let i++ fi + # Quote special characters but unquote standalone pipes before `--` + set -- "${(@)${(q@)@:1:$((i-1))}/#%\\|/|}" "${(q@)@:$i}" + # Just execute the command without *diff if there is only one argument if (( i + 1 == # )); then - # Quote special characters, unquote standalone pipes and replace %% with - # the only argument - eval "${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)@[$#]}}" + eval "${(@)${@:1:$((i-1))}//\%\%/$@[$#]}" return fi @@ -716,11 +717,10 @@ diffcmds() { cmdline=("$cmd") for arg in "${@:$((i+1))}"; do - # Add a layer of quotation but unquoting standalone pipes again, - # substitute placeholder and finally wrap in process substitution + # Substitute placeholder and wrap in process substitution cmdline+=( "$ps_sub" - "${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)arg}}" + "${(@)${@:1:$((i-1))}//\%\%/$arg}" ")" ) done