From 4b41e33cbcf8027b53ecae4467dc9232becb0420 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sat, 5 Nov 2016 00:27:47 +0100 Subject: 39389: when printf -v is used with an array use separate elements each time the format is reused --- Completion/Zsh/Command/_print | 17 +++++++++++------ Completion/Zsh/Type/_globquals | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'Completion') diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print index 38f17ab8e..8df094107 100644 --- a/Completion/Zsh/Command/_print +++ b/Completion/Zsh/Command/_print @@ -1,15 +1,18 @@ #compdef print printf -local state expl line eflag pflag rest ret=1 +local state expl line eflag pflag rflag rest ret=1 if [[ $service = print ]]; then # -e flag available only after -R eflag="${words[1,CURRENT-1][(r)-*R*]:+-e[enable escapes]}" + rflag='-r[ignore escape conventions of echo]' # -p flag only relevant if we have a coprocess (:>&p) 2>/dev/null && pflag='(-s -u -z)-p[print arguments to input of coprocess]' + [[ -n ${words[(r)-*f]} ]] && rflag='-r[disable reuse of format string]' + if [[ -n ${words[1,CURRENT][(r)-*P*]} ]]; then rest='*: :->prompt' else @@ -17,11 +20,11 @@ if [[ $service = print ]]; then fi _arguments -C -s -A "-*" -S \ - '(-f)-r[ignore escape conventions of echo]' \ + '-r[ignore escape conventions of echo]' \ '(-r -b -f -m -s -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \ '-b[recognise bindkey escape sequences]' \ - '-m[remove arguments matching specified pattern]' \ - '(-r -n -R -l -N -c)-f+[print arguments as for the printf builtin]:format:->printfformat' \ + '-m[remove arguments not matching specified pattern]:pattern' \ + '(-n -R -l -N -c)-f+[print arguments as for the printf builtin]:format:->printfformat' \ '(-u -p -z)-s[place results in the history list]' \ '(-c -f)-n[do not add a newline to the result]' \ '(-N -c -f)-l[print arguments separated by newlines]' \ @@ -33,11 +36,13 @@ if [[ $service = print ]]; then '(-n -l -N -f -C -s -z)-c[print arguments in columns]' \ '(-n -l -N -f -c -s -z)-C+[print arguments in specified number of columns]:columns' \ '(-s -p -z)-u+[specify file descriptor to print arguments to]:file descriptor:_file_descriptors' \ - '-v[store output in named parameter]:parameter:_parameters' \ + '(-s -z -p -u)-v[store output in named parameter]:parameter:_parameters' \ '(-s -p -u)-z[push arguments onto editing buffer stack]' \ '-D[substitute any arguments which are named directories using ~ notation]' \ '-P[perform prompt expansion]' \ - $pflag $eflag $rest && ret=0 + '(-X -f -a -C -c -z)-x+[expand leading tabs]:tab width' \ + '(-x -f -a -C -c -z)-X+[expand all tabs]:tab width' \ + $pflag $eflag $rflag $rest && ret=0 elif [[ $service = printf ]]; then state=printf fi diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals index 6eef16877..a904bdf0d 100644 --- a/Completion/Zsh/Type/_globquals +++ b/Completion/Zsh/Type/_globquals @@ -121,8 +121,7 @@ while [[ -n $PREFIX ]]; do tmatch=( s m h d w M ) if zstyle -t ":completion:${curcontext}:time-specifiers" verbose; then zstyle -s ":completion:${curcontext}:time-specifiers" list-separator sep || sep=-- - print -v tdisp -f "%s ${sep//(#m)[%\\]/$MATCH$MATCH} %s\0" ${tmatch:^^tdisp} - tdisp=( ${(0)tdisp} ) + print -v tdisp -f "%s ${sep//(#m)[%\\]/$MATCH$MATCH} %s" ${tmatch:^^tdisp} fi alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' -a tmatch" ) fi -- cgit 1.4.1