zsh:diffcmds: Do the quotation only once

This commit is contained in:
2024-03-24 17:54:11 +01:00
parent 09f437a860
commit 52e5d1ab4d

View File

@@ -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