From 1712c626339c3e7f40273d9e57906fab96a329a9 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 27 Aug 2016 18:44:47 +0000 Subject: 39109: _postfix: Use mailq to obtain queue id's. 'mailq' is usually in */bin (as opposed to */sbin) and so is more likely to be in $PATH. --- Completion/Unix/Command/_postfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 0ced6c24a..68115694f 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -1,7 +1,7 @@ #compdef postsuper _postfix_queue_id() { -compadd ${${(M)${(f)"$(postqueue -p)"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]} + compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]} } case $service in -- cgit v1.2.3 From 823bb6fe8572f176f4433b12677ea90e06ca9d53 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 27 Aug 2016 18:44:48 +0000 Subject: 39107: _postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper'. --- ChangeLog | 3 +++ Completion/Unix/Command/_postfix | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index d33d9b2c0..27e56d6fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-08-30 Daniel Shahaf + * 39107: Completion/Unix/Command/_postfix: Complete + 'postqueue'. Also minor tweaks to 'postsuper'. + * 39109: Completion/Unix/Command/_postfix: Use mailq to obtain queue id's. diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 68115694f..2e6a0a04d 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -1,4 +1,4 @@ -#compdef postsuper +#compdef postqueue postsuper _postfix_queue_id() { compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]} @@ -6,15 +6,25 @@ _postfix_queue_id() { case $service in (postsuper) - _arguments -C \ + _arguments -C -s : \ '-p[purge old tempfiles]' \ '-s[structure check and repair]' \ - '-v[verbose]' \ + '*-v[verbose]' \ '-c[configdir]:config dir:_files -/' \ '-d[delete]:queue id:_postfix_queue_id' \ '-h[hold]:queue id:_postfix_queue_id' \ '-H[release]:queue id:_postfix_queue_id' \ - '-r[requeue]:queue id:_postfix_queue_id' \ + '*-r[requeue]:queue id, or "ALL":_postfix_queue_id' \ '1:queue:(hold incoming active deferred)' ;; + (postqueue) + _arguments -C -s : \ + '*-v[enable verbose logging]' \ + '-c[configdir]:config dir:_files -/' \ + '(-f -i -j -p -s)-f[flush the queue]' \ + '(-f -i -j -p -s)-i[immediately deliver one message]:queue id:_postfix_queue_id' \ + '(-f -i -j -p -s)-j[print the queue in json]' \ + '(-f -i -j -p -s)-p[print the queue in traditional format]' \ + '(-f -i -j -p -s)-s[immediately deliver messages to specified site]:site:_hosts' + ;; esac -- cgit v1.2.3 From d916ba1a00a809187219e571b94ddd299a39003f Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 27 Aug 2016 18:44:49 +0000 Subject: 39110: _postfix: Complete 'postconf'. --- ChangeLog | 2 + Completion/Unix/Command/_postfix | 107 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index 27e56d6fb..863a58682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-08-30 Daniel Shahaf + * 39110: Completion/Unix/Command/_postfix: Complete 'postconf'. + * 39107: Completion/Unix/Command/_postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper'. diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 2e6a0a04d..8880dbf90 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -1,9 +1,36 @@ -#compdef postqueue postsuper +#compdef postconf postqueue postsuper + +# Last updated from postfix 3.1.0. + +local context state state_descr line +typeset -A opt_args +integer NORMARG _postfix_queue_id() { compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]} } +_postfix_main_cf_parameter() { + local expl + # Note for the future: if $mail_version >= 3.1, we can pass -H instead of + # stripping the = signs by hand. + _wanted parameters expl 'main.cf parameter' compadd "$@" -- ${${(f)"$(_call_program postconf-defaults "${(q)words[1]} -d")"}%% =*} +} + +_postfix_main_cf_parameter_and_value() { + # Note: be careful not to accidentally run 'postconf foo=bar' here. + # + # The '-P 1' syntax chooses the shortest match. If the '1' were removed, + # completing «postconf foo=bar=» would change main.cf. So, don't remove + # it. + if compset -P 1 '*='; then + local value="`_call_program postconf-get-value-at-dir "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -h -- ${(q)IPREFIX%=}"`" + [[ -n $value ]] && compadd "$@" -- $value + else + _postfix_main_cf_parameter -S= + fi +} + case $service in (postsuper) _arguments -C -s : \ @@ -27,4 +54,82 @@ case $service in '(-f -i -j -p -s)-p[print the queue in traditional format]' \ '(-f -i -j -p -s)-s[immediately deliver messages to specified site]:site:_hosts' ;; + (postconf) + local -a file_ops=(-b -t -a -A -l -m -T) + local -a modes=(-F -M -P $file_ops -p) + local -a only_for_p=(-C -d -h -n) + local -a only_for_asterisk_dot_cf=(-e -f -o -x) + local -a args=( + # global + '-c[configdir]:config dir:_files -/' \ + '*-v[enable verbose logging]' + + # mode selection + "($modes $only_for_p -X -#)"'-F[operate on master.cf entry fields]' + "($modes $only_for_p -H )"'-M[operate on master.cf services entries]' + "($modes $only_for_p -#)"'-P[operate on master.cf parameter settings]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-b[display DSN text, expanded]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-t[display DSN text, unexpanded]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-a[list available SASL server plug-ins]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-A[list available SASL client plug-ins]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-l[list supported mailbox locking methods]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-m[list supported lookup table types]' + "($modes )"'-p[(default) print main.cf settings]' + "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-T[print TLS information]:mode:(( + compile-version\:"OpenSSL compile-time version" + run-version\:"OpenSSL run-time version" + public-key-algorithms\:"supported public-key algorithms" + ))' + + # other options; comments indicate modes: + # -p only + '-C[display parameters from the specified class]:parameter class:(builtin service user all)' + '-d[print default values]' + '-h[print value only]' + '-n[show parameters changed in main.cf]' + + # all except $file_ops: + '-e[change parameter values]' + '-f[fold long output lines]' + '-o[set parameter value for this operation]: :_postfix_main_cf_parameter_and_value' + '-x[expand '\''$name'\'' in parameter values]' + + # -p -F -P only + '-H[show parameter name only]' + # -p -M -P only + '-X[remove parameters from main.cf/master.cf]' + # -p -M only + '-#[comment out parameters in main.cf/master.cf]' + + # $state + '*: :->positional' + ) + _arguments -C -s -S -n : "$args[@]" + + case $state in + (positional) + # Simulate the default + if [[ -z $opt_args[(i)${(j.|.)modes}] ]]; then + opt_args[-p]="" + fi + if [[ -n $opt_args[(i)(-b|-t)] ]]; then + local expl + if (( CURRENT == NORMARG )); then + _wanted files expl 'template file, or "" for default' _files + else + _nothing + fi + elif [[ -n $opt_args[(i)${(j.|.)file_ops}] ]]; then + _nothing + elif (( $+opt_args[-p] )); then + if (( $+opt_args[-e] )); then + _postfix_main_cf_parameter_and_value + else + _postfix_main_cf_parameter + fi + else # one of the master.cf modes: -M -F -P + _message "arguments for $opt_args[(i)${(j.|.)modes}] mode" + fi + esac + ;; esac -- cgit v1.2.3 From 4ce0b1c0985f469ac93341185f06dd8bdb2c91d0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 27 Aug 2016 18:44:50 +0000 Subject: 39108 (tweaked): _postfix: Support $enable_long_queue_ids. Note that this not only adds a second compadd invocation but also adds a space to the first compadd invocation, to prevent the start of a new-style queue id from matching as an old-style queue id. --- ChangeLog | 3 +++ Completion/Unix/Command/_postfix | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index 863a58682..4d2de8d86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-08-30 Daniel Shahaf + * 39108: Completion/Unix/Command/_postfix: Support + $enable_long_queue_ids. + * 39110: Completion/Unix/Command/_postfix: Complete 'postconf'. * 39107: Completion/Unix/Command/_postfix: Complete diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 8880dbf90..ab9518212 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -7,7 +7,13 @@ typeset -A opt_args integer NORMARG _postfix_queue_id() { - compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]} + local -a lines=( ${(f)"$(_call_program mailq 'mailq')"} ) + + # $enable_long_queue_ids = no + compadd "$@" -- ${${(M)lines:#(#s)([0-9A-F]## )*}/(#s)(#b)([0-9A-F]##)*/$match[1]} + + # $enable_long_queue_ids = yes + compadd "$@" -- ${${${(M)lines:#(#s)[0-9bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ](#c10)z*}%% *}%[*!]} } _postfix_main_cf_parameter() { -- cgit v1.2.3 From 972423629f115b710c385cff0daa60182e5f33e6 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 2 Sep 2016 05:48:24 +0000 Subject: unposted: _postfix_queue_id: Unbreak completion of short queue ids of held/active messages, broken in 39108. --- ChangeLog | 6 +++++- Completion/Unix/Command/_postfix | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index 989d16e84..0b6d6b3de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2016-09-02 Daniel Shahaf + * unposted: Completion/Unix/Command/_postfix: _postfix_queue_id: + Unbreak completion of short queue ids of held/active messages, + broken in 39108. + * 39154: Completion/Unix/Type/_files: -/ with list-dirs-first resulted in a bad pattern, thus aborting completion partway. @@ -28,7 +32,7 @@ 2016-08-30 Daniel Shahaf - * 39108: Completion/Unix/Command/_postfix: Support + * 39108 (tweaked): Completion/Unix/Command/_postfix: Support $enable_long_queue_ids. * 39110: Completion/Unix/Command/_postfix: Complete 'postconf'. diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index ab9518212..528034ef8 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -10,7 +10,7 @@ _postfix_queue_id() { local -a lines=( ${(f)"$(_call_program mailq 'mailq')"} ) # $enable_long_queue_ids = no - compadd "$@" -- ${${(M)lines:#(#s)([0-9A-F]## )*}/(#s)(#b)([0-9A-F]##)*/$match[1]} + compadd "$@" -- ${${(M)lines:#(#s)([0-9A-F]##([*!]|) )*}/(#s)(#b)([0-9A-F]##)*/$match[1]} # $enable_long_queue_ids = yes compadd "$@" -- ${${${(M)lines:#(#s)[0-9bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ](#c10)z*}%% *}%[*!]} -- cgit v1.2.3 From 6914fb298d5b736a331a87f6e2510903c6e89b84 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Sep 2016 05:14:33 +0000 Subject: 39312 (tweaked): _postfix (postconf): Complete only applicable parameters for -X and -#. Unposted tweak: change the tag and description in the _describe call. --- ChangeLog | 3 +++ Completion/Unix/Command/_postfix | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index 87b766b10..626647c07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-09-16 Daniel Shahaf + * 39312 (tweaked): Completion/Unix/Command/_postfix: _postfix + (postconf): Complete only applicable parameters for -X and -#. + * 39310/0010: Src/Zle/compmatch.c: internals: match_str: Simplify expression. diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 528034ef8..26a262bd3 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -16,11 +16,31 @@ _postfix_queue_id() { compadd "$@" -- ${${${(M)lines:#(#s)[0-9bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ](#c10)z*}%% *}%[*!]} } +# The first argument must be either 'd' or 'n', to complete parameters in +# `postconf -d -H` or `postconf -n -H` output, respectively. _postfix_main_cf_parameter() { - local expl - # Note for the future: if $mail_version >= 3.1, we can pass -H instead of - # stripping the = signs by hand. - _wanted parameters expl 'main.cf parameter' compadd "$@" -- ${${(f)"$(_call_program postconf-defaults "${(q)words[1]} -d")"}%% =*} + local -a expl + local kind + + kind=$1; shift + case $kind in + (d) + # Note for the future: if $mail_version >= 3.1, we can pass -H instead of + # stripping the = signs by hand. + # + # don't bother to add -c in this case: the defaults don't depend on the config dir. + _wanted parameters expl 'main.cf parameter' compadd "$@" -- \ + ${${(f)"$(_call_program postconf_-d "${(q)words[1]} -$kind")"}%% =*} + ;; + (n) + # Show the values too. + local -a kv=( ${${(f)"$(_call_program postconf_-n "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -$kind")"}/ = /:} ) + _describe -t parameters 'main.cf parameter' kv + ;; + (*) + return 1 # can't happen due to the guard above + ;; + esac } _postfix_main_cf_parameter_and_value() { @@ -33,7 +53,7 @@ _postfix_main_cf_parameter_and_value() { local value="`_call_program postconf-get-value-at-dir "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -h -- ${(q)IPREFIX%=}"`" [[ -n $value ]] && compadd "$@" -- $value else - _postfix_main_cf_parameter -S= + _postfix_main_cf_parameter d -S= fi } @@ -130,8 +150,10 @@ case $service in elif (( $+opt_args[-p] )); then if (( $+opt_args[-e] )); then _postfix_main_cf_parameter_and_value + elif [[ -n $opt_args[(i)(-X|-[#])] ]]; then + _postfix_main_cf_parameter n else - _postfix_main_cf_parameter + _postfix_main_cf_parameter d fi else # one of the master.cf modes: -M -F -P _message "arguments for $opt_args[(i)${(j.|.)modes}] mode" -- cgit v1.2.3 From d523ddaba2cd160343b54d3e38ea001c63a87dc6 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 16 Sep 2016 04:02:08 +0000 Subject: unposted: _postfix: Correct quoting in _call_program invocations. Fixes completion when the command name ('postconf') or the argument to the -c option ('/etc/postfix') are quoted on the command line, as in % postconf -c '/etc/postfix' ... --- ChangeLog | 3 +++ Completion/Unix/Command/_postfix | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'Completion/Unix/Command/_postfix') diff --git a/ChangeLog b/ChangeLog index 626647c07..0d130b040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-09-16 Daniel Shahaf + * unposted: Completion/Unix/Command/_postfix: Correct quoting + in _call_program invocations. + * 39312 (tweaked): Completion/Unix/Command/_postfix: _postfix (postconf): Complete only applicable parameters for -X and -#. diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 26a262bd3..006c950e3 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -30,11 +30,11 @@ _postfix_main_cf_parameter() { # # don't bother to add -c in this case: the defaults don't depend on the config dir. _wanted parameters expl 'main.cf parameter' compadd "$@" -- \ - ${${(f)"$(_call_program postconf_-d "${(q)words[1]} -$kind")"}%% =*} + ${${(f)"$(_call_program postconf_-d "${words[1]} -$kind")"}%% =*} ;; (n) # Show the values too. - local -a kv=( ${${(f)"$(_call_program postconf_-n "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -$kind")"}/ = /:} ) + local -a kv=( ${${(f)"$(_call_program postconf_-n "${words[1]} ${opt_args[-c]+"-c ${opt_args[-c]}"} -$kind")"}/ = /:} ) _describe -t parameters 'main.cf parameter' kv ;; (*) @@ -50,7 +50,7 @@ _postfix_main_cf_parameter_and_value() { # completing «postconf foo=bar=» would change main.cf. So, don't remove # it. if compset -P 1 '*='; then - local value="`_call_program postconf-get-value-at-dir "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -h -- ${(q)IPREFIX%=}"`" + local value="`_call_program postconf-get-value-at-dir "${words[1]} ${opt_args[-c]+"-c ${opt_args[-c]}"} -h -- ${(q)IPREFIX%=}"`" [[ -n $value ]] && compadd "$@" -- $value else _postfix_main_cf_parameter d -S= -- cgit v1.2.3