zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Fix getent completion
Date: Thu, 27 Oct 2011 21:28:13 +0200	[thread overview]
Message-ID: <1319743693-10790-1-git-send-email-mikachu@gmail.com> (raw)

getent --help now looks like this:

Supported databases:
ahosts ahostsv4 ahostsv6 aliases ethers group gshadow hosts netgroup
networks passwd protocols rpc services shadow

For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

which results in completion like this:
% getent <tab>
===database
\<http://www.gnu.org/software/libc/bugs.html\>.  aliases  hosts          please     services
For                                              bug      instructions,  protocols  shadow
ahosts                                           ethers   netgroup       reporting        
ahostsv4                                         group    networks       rpc              
ahostsv6                                         gshadow  passwd         see:             

Rather than change the -1 to -3, this should still work with old versions that don't have extra lines after the databases output.

diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent               
index 57d2ec2..9644fa3 100755
--- a/Completion/Unix/Command/_getent
+++ b/Completion/Unix/Command/_getent
@@ -25,8 +25,9 @@ case $state in
   ;;
   databases)
     if [[ $is_gnu = gnu ]]; then
-      databases=( ${=${${(f)"$(_call_program databases $words[1] --help \
-          2>/dev/null)"}[(r)Supported*,-1]}[2,-1]} )
+      databases=( "${(@)${(@f)$(_call_program databases $words[1] --help \
+                   2>/dev/null)}[(r)Supported*,-1]}" )
+      databases=( "${=${(@)databases[2,${(@)databases[(i)]}-1]}}" )
     else
       databases=( passwd group hosts ipnodes services protocols ethers networks netmasks )
     fi
-- 
1.7.5.4


                 reply	other threads:[~2011-10-27 19:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319743693-10790-1-git-send-email-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).