zsh:diffcmds: Do the quotation only once
This commit is contained in:
@@ -691,11 +691,12 @@ diffcmds() {
|
|||||||
let i++
|
let i++
|
||||||
fi
|
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
|
# Just execute the command without *diff if there is only one argument
|
||||||
if (( i + 1 == # )); then
|
if (( i + 1 == # )); then
|
||||||
# Quote special characters, unquote standalone pipes and replace %% with
|
eval "${(@)${@:1:$((i-1))}//\%\%/$@[$#]}"
|
||||||
# the only argument
|
|
||||||
eval "${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)@[$#]}}"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -716,11 +717,10 @@ diffcmds() {
|
|||||||
|
|
||||||
cmdline=("$cmd")
|
cmdline=("$cmd")
|
||||||
for arg in "${@:$((i+1))}"; do
|
for arg in "${@:$((i+1))}"; do
|
||||||
# Add a layer of quotation but unquoting standalone pipes again,
|
# Substitute placeholder and wrap in process substitution
|
||||||
# substitute placeholder and finally wrap in process substitution
|
|
||||||
cmdline+=(
|
cmdline+=(
|
||||||
"$ps_sub"
|
"$ps_sub"
|
||||||
"${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)arg}}"
|
"${(@)${@:1:$((i-1))}//\%\%/$arg}"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user