zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: zsh workers <zsh-workers@zsh.org>
Subject: [PATCH] Completion: Fix _pick_variant checks for GNU, improve _getent
Date: Thu, 21 Feb 2019 22:03:03 -0600	[thread overview]
Message-ID: <1E0D504D-11CF-4269-B21F-2F07EF7BEBFB@dana.is> (raw)

I noticed that GNU getent isn't detected correctly due to an out-of-date
_pick_variant pattern. I've fixed that and a few others by changing EGLIBC to
just GLIBC. I've also added 'Free Soft' where it wasn't present, just in case

Since i was there, i partially fixed `getent -s` completion as well

dana


diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent
index 7f4e8bc9c..0fb9a0af4 100644
--- a/Completion/Unix/Command/_getent
+++ b/Completion/Unix/Command/_getent
@@ -5,24 +5,28 @@ local services databases keys
 local -a args
 typeset -A opt_args
 
-if _pick_variant -r is_gnu gnu='(GNU|EGLIBC|Gentoo)' unix --version; then
+if _pick_variant -r is_gnu gnu='(Free Soft|GNU|GLIBC|Gentoo)' unix --version; then
   args+=(
     '(- 1 *)'{-\?,--help}'[display help information]'
     '(- 1 *)--usage[display a short usage message]'
     '(- 1 *)'{-V,--version}'[display version information]'
-    {-s,--service=}'[specify service configuration to use]:service:->services'
+    '*'{-s+,--service=}'[specify service configuration to use]: :->services'
     '(-i --no-idn)'{-i,--no-idn}'[disable IDN encoding]'
   )
 fi
 
-_arguments -C "$args[@]" \
+_arguments -s -S -C "$args[@]" \
   '1:database:->databases' \
   '*:key:->keys' && ret=0
 
 case $state in
   services)
-    services=( /lib/libnss*(-.:fr:t:s/libnss_//) )
-    _wanted services expl service compadd ${services%-*} && ret=0
+    # @todo GNU getent supports both `-s svc` and `-s db:svc`; we only complete
+    # the former here
+    services=( {,/usr}/lib/{,*-linux-gnu/}libnss_*(N-.:fr:t:s/libnss_//) )
+    _wanted services expl 'service or database:service' \
+      compadd ${(u)services%-*} \
+    && ret=0
   ;;
   databases)
     if [[ $is_gnu = gnu ]]; then

diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv
index d040be756..e6daad938 100644
--- a/Completion/Unix/Command/_iconv
+++ b/Completion/Unix/Command/_iconv
@@ -2,7 +2,7 @@
 
 local expl curcontext="$curcontext" state line variant ret=1
 
-if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC|Gentoo)' unix --version; then
+if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(Free Soft|GNU*libc|GLIBC|Gentoo)' unix --version; then
   local -a args
   local exargs="-l --list -? --help --usage --version -V"
 
diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd
index 1de1659a5..3c7b088df 100644
--- a/Completion/Unix/Command/_ldd
+++ b/Completion/Unix/Command/_ldd
@@ -1,6 +1,6 @@
 #compdef ldd
 
-if _pick_variant gnu='(Free Soft|GNU|EGLIBC|Gentoo)' unix --version; then
+if _pick_variant gnu='(Free Soft|GNU|GLIBC|Gentoo)' unix --version; then
   args=(
     '(- *)--version[display version information]'
     '(- *)--help[display help information]'
diff --git a/Completion/Unix/Command/_locale b/Completion/Unix/Command/_locale
index 59e04a282..a7fd88f65 100644
--- a/Completion/Unix/Command/_locale
+++ b/Completion/Unix/Command/_locale
@@ -3,7 +3,7 @@
 local curcontext="$curcontext" state state_descr line expl ret=1
 typeset -A opt_args; local -a specs aopts
 
-if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then
+if _pick_variant gnu='(Free Soft|GNU|GLIBC)' unix --version; then
 
   local exargs="-? --help --usage -V --version"
 
diff --git a/Completion/Unix/Command/_localedef b/Completion/Unix/Command/_localedef
index 4d4b4bbe3..57637e3ec 100644
--- a/Completion/Unix/Command/_localedef
+++ b/Completion/Unix/Command/_localedef
@@ -3,7 +3,7 @@
 local curcontext="$curcontext" state line expl ret=1
 typeset -A opt_args
 
-if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then
+if _pick_variant gnu='(Free Soft|GNU|GLIBC)' unix --version; then
 
   local exargs="-? --help --usage -V --version"
   _arguments -A "-*" -C -S -s \


                 reply	other threads:[~2019-02-22  4:03 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=1E0D504D-11CF-4269-B21F-2F07EF7BEBFB@dana.is \
    --to=dana@dana.is \
    --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).