about summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_cpio26
-rw-r--r--Completion/Unix/Command/_grep13
-rw-r--r--Completion/Unix/Command/_iconv12
-rw-r--r--Completion/Unix/Command/_ls13
-rw-r--r--Completion/Unix/Command/_make17
-rw-r--r--Completion/Unix/Command/_netcat4
-rw-r--r--Completion/Unix/Command/_zcat14
7 files changed, 20 insertions, 79 deletions
diff --git a/Completion/Unix/Command/_cpio b/Completion/Unix/Command/_cpio
index 61c4d76ac..280a8930f 100644
--- a/Completion/Unix/Command/_cpio
+++ b/Completion/Unix/Command/_cpio
@@ -1,33 +1,23 @@
 #compdef cpio
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-
-local cmd=$service args ig curcontext="$curcontext" state line
+local args ig curcontext="$curcontext" state line
 local expl ret
 local fmts='(bar bin odc newc crc tar ustar hpbin hpodc)'
 
-if (( ! $+_is_gnu[$cmd] )); then
-  if [[ $(_call_program version $cmd --version </dev/null 2>/dev/null) = *GNU* ]]
-  then
-    _is_gnu[$cmd]=yes
-  else
-    _is_gnu[$cmd]=
-  fi
-fi 
-ig=$_is_gnu[$cmd]
+_pick_variant -r ig gnu=GNU unix --version
 
-if (( $CURRENT == 2 )); then
+if (( CURRENT == 2 )); then
    # Complete arguments 
    args=('-o[create archive]' '-i[extract from archive]'
    '-p[run as filter on directory tree]')
-   [[ -n $ig ]] && args=($args '--create[create archive]'
+   [[ $ig = gnu ]] && args=($args '--create[create archive]'
    '--extract[extract from archive]' 
    '--pass-through[run as filter on directory tree]'
    '--help[show help text]' '--version[show version information]')
 else
   if [[ -n ${words[(r)(-o*|-[^-]*o*|--create)]} ]]; then
-    # Optiona for creating archive
-    if [[ -n $ig ]]; then
+    # Options for creating archive
+    if [[ $ig = gnu ]]; then
 	args=(
 	   '--file=:archive file:->afile'
 	   "--format=:format type:$fmts"
@@ -51,7 +41,7 @@ else
 	  '-O[set output archive file]:output archive file:_files'
 	 )
   elif [[ -n ${words[(r)(-i*|-[^-]*i*|--extract)]} ]]; then
-    if [[ -n $ig ]]; then
+    if [[ $ig = gnu ]]; then
       args=('--file=:archive file:->afile'
 	    "--format=:format type:$fmts"
 	    '--make-directories' '--nonmatching' 
@@ -90,7 +80,7 @@ else
 	  '*:pattern to extract'
 	  )
   elif [[ -n ${words[(r)(-p*|-[^-]*p*|--pass-through)]} ]]; then
-    if [[ -n $ig ]]; then
+    if [[ $ig = gnu ]]; then
       args=('--null' '--reset-access-time' '--make-directories'
             '--link' '--quiet' '--preserve-modification-time'
 	    '--unconditional' '--verbose' '--dot' '--dereference'
diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep
index 5dbbe025e..98b4256f8 100644
--- a/Completion/Unix/Command/_grep
+++ b/Completion/Unix/Command/_grep
@@ -16,17 +16,6 @@ else
   command="$words[1]"
 fi
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-
-if (( ! $+_is_gnu[$command] )); then
-  if [[ $(_call_program version $command --help </dev/null 2>/dev/null) = *gnu* ]]
-  then
-    _is_gnu[$command]=yes
-  else
-    _is_gnu[$command]=
-  fi
-fi
-
 if [[ $service != [ef]grep ]]; then
   matchers='(--extended-regexp --fixed-strings --basic-regexp --perl-regexp -E -F -G -P)'
   arguments+=(
@@ -77,7 +66,7 @@ arguments=( $arguments[@]
 )
 
 # remove long options?
-[[ -z "$_is_gnu[$command]" ]] &&
+_pick_variant -c "$command" gnu=gnu unix --help ||
     arguments=( ${arguments:#(|*\)(\*|))--*} )
 
 _arguments -s $arguments[@]
diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv
index 3764c4634..490d70bc8 100644
--- a/Completion/Unix/Command/_iconv
+++ b/Completion/Unix/Command/_iconv
@@ -2,17 +2,7 @@
 
 local expl curcontext="$curcontext" state line codeset LOCPATH
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-if (( ! $+_is_gnu[$words[1]] )); then
-  if [[ $(_call_program version $words[1] --version </dev/null 2>/dev/null) = *GNU* ]]; 
-  then
-    _is_gnu[$words[1]]=yes
-  else
-    _is_gnu[$words[1]]=
-  fi
-fi
-
-if [[ -n "$_is_gnu[$words[1]]" ]]; then
+if _pick_variant gnu=GNU unix --version; then
 
   _arguments -C \
     {'(--from-code --list)-f','(-f --list)--from-code='}'[specify code set of input file]:code set:->codeset' \
diff --git a/Completion/Unix/Command/_ls b/Completion/Unix/Command/_ls
index b9588c5f4..33c3ca652 100644
--- a/Completion/Unix/Command/_ls
+++ b/Completion/Unix/Command/_ls
@@ -3,17 +3,6 @@
 
 local arguments
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-
-if (( ! $+_is_gnu[$words[1]] )); then
-  if [[ $(_call_program version $words[1] --help </dev/null 2>/dev/null) = *gnu* ]]
-  then
-    _is_gnu[$words[1]]=yes
-  else
-    _is_gnu[$words[1]]=
-  fi
-fi
-
 arguments=(
   '(--all -a -A --almost-all)'{--all,-a}'[list entries starting with .]'
   '(--almost-all -A -a --all)'{--almost-all,-A}'[list all except . and ..]'
@@ -79,7 +68,7 @@ arguments=(
 )
 
 # remove long options?
-[[ -z "$_is_gnu[$words[1]]" ]] &&
+_pick_variant gnu=gnu unix --help ||
     arguments=( ${${${arguments:#(|*\))--*}//--[^ )]#/}/\( #\)/} )
 
 _arguments -s $arguments
diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index df28eac60..53958c0d0 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -1,17 +1,8 @@
 #compdef make gmake pmake dmake
 
-local prev="$words[CURRENT-1]" file expl tmp
+local prev="$words[CURRENT-1]" file expl tmp is_gnu
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-
-if (( ! $+_is_gnu[$words[1]] )); then
-  if [[ $(_call_program version $words[1] -v -f /dev/null </dev/null 2>/dev/null) = *GNU* ]]
-  then
-    _is_gnu[$words[1]]=yes
-  else
-    _is_gnu[$words[1]]=
-  fi
-fi
+_pick_variant -r is_gnu gnu=GNU unix -v -f
 
 if [[ "$prev" = -[CI] ]]; then
   _files -/
@@ -25,14 +16,14 @@ else
     file=Makefile
   elif [[ -e makefile ]]; then
     file=makefile
-  elif [[ -n "$_is_gnu[$words[1]]" && -e GNUmakefile ]]; then
+  elif [[ $is_gnu = gnu && -e GNUmakefile ]]; then
     file=GNUmakefile
   else
     file=''
   fi
 
   if [[ -n "$file" ]] && _tags targets; then
-    if [[ -n "$_is_gnu[$words[1]]" ]] &&
+    if [[ $is_gnu = gnu ]] &&
        zstyle -t ":completion:${curcontext}:targets" call-command; then
       tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:) )
     else
diff --git a/Completion/Unix/Command/_netcat b/Completion/Unix/Command/_netcat
index d5e854e12..082b8afde 100644
--- a/Completion/Unix/Command/_netcat
+++ b/Completion/Unix/Command/_netcat
@@ -3,6 +3,10 @@
 local curcontext="$curcontext" state line expl
 typeset -A opt_args
 
+# handle name clash with the nedit client
+[[ $service = nc ]] && ! _pick_variant netcat=connect nedit -h &&
+    _nedit && return
+
 if (( ! $+_nc_args )); then
   local help="$(_call_program options nc -h < /dev/null 2>&1)"
   local -A optionmap
diff --git a/Completion/Unix/Command/_zcat b/Completion/Unix/Command/_zcat
index dac7493b2..6dd4ecd7b 100644
--- a/Completion/Unix/Command/_zcat
+++ b/Completion/Unix/Command/_zcat
@@ -1,18 +1,6 @@
 #compdef zcat
 
-(( $+_is_gnu )) || typeset -gA _is_gnu
-
-if (( ! $+_is_gnu[$words[1]] )); then
-  if [[ $(_call_program version $words[1] --license </dev/null 2>&1) = *GNU* ]]
-  then
-    _is_gnu[$words[1]]=yes
-  else
-    _is_gnu[$words[1]]=
-  fi
-fi
-
-if [[ -n "$_is_gnu[$words[1]]" ]]
-then
+if _pick_variant gnu=GNU unix --license; then
   _gzip "$@"
 else
   _compress "$@"