help / Atom feed
* [PATCH] Completion: Fix _pick_variant checks for GNU, improve _getent
@ 2019-02-22  4:03 dana
  0 siblings, 0 replies; 1+ messages in thread
From: dana @ 2019-02-22  4:03 UTC (permalink / raw)
  To: zsh workers

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


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
     '(- 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]'
-_arguments -C "$args[@]" \
+_arguments -s -S -C "$args[@]" \
   '1:database:->databases' \
   '*:key:->keys' && ret=0
 case $state in
-    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
     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
     '(- *)--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 \

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22  4:03 [PATCH] Completion: Fix _pick_variant checks for GNU, improve _getent dana


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/ public-inbox