From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22466 invoked by alias); 14 Sep 2016 05:15:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39312 Received: (qmail 24697 invoked from network); 14 Sep 2016 05:15:29 -0000 X-Qmail-Scanner-Diagnostics: from out4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.28):SA:0(0.0/5.0):. Processed in 0.199481 secs); 14 Sep 2016 05:15:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=+TZgboUFWbUnY6I06fy6uE81P1s=; b=ath8U1 X4AI1aYCJA2OrLck666VJjl19SS/HAqni9UvyJDTOaoTmiH4624afX4ehxvEci/h 1ImLB7dtb5hfoU0OTSa/Raw5L65hGzF+A/cJedEdGGJ02wfisAbNUYy7/exKOUF4 rGbED59zb+Mr1g2yd2ym7EeKbIXHfyBn+c7Bw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-sasl-enc:x-sasl-enc; s=smtpout; bh=+TZgboUFWbUnY6I06fy6uE81P1 s=; b=nm+MZCigrTg34CP5XVDVF8Xqd4zWMnpVBuXqf/2qc1UA0WetFR8wCu6rn5 F4MfEEp1Y8y8Ivt4yuBRzxxUSnPtS4cUuL+q1l6YVGfZqvPDnhqff64k5wqqelKC EXbnkYohD/QSLeoau37da37O8ECZlq9RbyRx3uNwR94ytkAJY= X-Sasl-enc: UbGCgQN/dPGNC1rJqBEj3arcqWq1M3f7UcbYFT6Hxi6/ 1473830125 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] _postfix (postconf): Complete only applicable parameters for -X and -#. Date: Wed, 14 Sep 2016 05:14:33 +0000 Message-Id: <1473830073-331-1-git-send-email-danielsh@fujitsu.shahaf.local2> X-Mailer: git-send-email 2.1.4 --- One question about this patch: % /usr/sbin/postconf -X zsh: do you wish to see all 112 possibilities (28 lines)? I don't understand why it says "112". I expected it to say "32" since my `postconf -n` output has 32 lines. Without this patch, it says "928 possibilities", as expected, since my `postconf -d` output [what the before-the-patch code uses] has 928 lines. Why does it say 112 rather than 32? Thanks, Daniel Completion/Unix/Command/_postfix | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 528034e..afd56b7 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 parameters 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"