zsh:diffcmds: Do not unquote pipes in args list
diffcmds echo foo %% cat -- '|'
is expected to output `foo | cat` and not `foo`.
Fix this by changing the order of the substitution and {,un}quoting.
This commit is contained in:
@@ -693,10 +693,9 @@ diffcmds() {
|
|||||||
|
|
||||||
# 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, replace %% with the only argument and
|
# Quote special characters, unquote standalone pipes and replace %% with
|
||||||
# unquote pipes in arguments that consist of only the quoted pipe
|
# the only argument
|
||||||
# character.
|
eval "${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)@[$#]}}"
|
||||||
eval "${(@)${(q@)${@:1:$((i-1))}//\%\%/${@[$#]}}/#%\\|/|}"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -717,11 +716,11 @@ diffcmds() {
|
|||||||
|
|
||||||
cmdline=("$cmd")
|
cmdline=("$cmd")
|
||||||
for arg in "${@:$((i+1))}"; do
|
for arg in "${@:$((i+1))}"; do
|
||||||
# Substitute placeholder, wrap in process substitution and add a layer
|
# Add a layer of quotation but unquoting standalone pipes again,
|
||||||
# of quotation but unquoting single pipes again.
|
# substitute placeholder and finally wrap in process substitution
|
||||||
cmdline+=(
|
cmdline+=(
|
||||||
"$ps_sub"
|
"$ps_sub"
|
||||||
"${(@)${(q@)${@:1:$((i-1))}//\%\%/$arg}/#%\\|/|}"
|
"${(@)${(@)${(q@)@:1:$((i-1))}/#%\\|/|}//\%\%/${(q)arg}}"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user