Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Fix getent completion



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



Messages sorted by: Reverse Date, Date, Thread, Author