zsh:diffcmds: Do the quotation only once
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user