about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/_arguments44
-rw-r--r--Completion/Linux/_rpm54
2 files changed, 58 insertions, 40 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index 60b037812..6597c531f 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -6,7 +6,7 @@
 setopt localoptions extendedglob
 
 local args rest ws cur nth def nm expl descr action opt arg tmp xor
-local single uns ret=1 soptseq soptseq1 sopts prefix _line odescr
+local single uns ret=1 aret soptseq soptseq1 sopts prefix _line odescr
 local beg optbeg argbeg nargbeg inopt inrest fromrest cmd="$words[1]"
 local matched curopt
 
@@ -488,7 +488,7 @@ while [[ cur -gt 0 ]]; do
           fi
 	  if [[ "$def" = [^*]*[^\\]:*[^\\]:* ]]; then
             def="${def#?*[^\\]:*[^\\]:}"
-          else
+          elif [[ "$def" != \** ]]; then
             def=''
 	  fi
         fi
@@ -548,7 +548,7 @@ while [[ cur -gt 0 ]]; do
               def="${def#?*[^\\]:*[^\\]:}"
 	      optbeg="$beg"
 	      argbeg="$beg"
-            else
+            elif [[ "$def" != \** ]]; then
               def=''
             fi
 	  fi
@@ -560,12 +560,16 @@ while [[ cur -gt 0 ]]; do
 
       if [[ -n "$uns" ]]; then
         uns="${(@j::)${(v)=xors[(I)${ws[1][1]}[$uns]]}#[-+]}"
-	tmp=(
-	  "opts[${(@)^opts[(I)${ws[1][1]}[$uns]]}]"
-	  "dopts[${(@)^dopts[(I)${ws[1][1]}[$uns]]}]"
-	  "odopts[${(@)^odopts[(I)${ws[1][1]}[$uns]]}]"
-	)
-	(( $#tmp )) && unset "$tmp[@]"
+	if  [[ -n "$uns" ]]; then
+	  tmp=(
+	    "opts[${(@)^opts[(I)${ws[1][1]}[$uns]]}]"
+	    "dopts[${(@)^dopts[(I)${ws[1][1]}[$uns]]}]"
+	    "odopts[${(@)^odopts[(I)${ws[1][1]}[$uns]]}]"
+	    "xors[${(@)^xors[(I)${ws[1][1]}[$uns]]}]"
+	  )
+	  odescr=( "${(@)odescr:#${ws[1][1]}[$uns]:*}" )
+	  (( $#tmp )) && unset "$tmp[@]"
+        fi
       fi
 
       # If we didn't find a matching option description and we were
@@ -672,12 +676,16 @@ if [[ -z "$def" || "$def" = :* ]]; then
 
   if [[ -n "$uns" ]]; then
     uns="${(@j::)${(v)=xors[(I)${ws[1][1]}[$uns]]}#[-+]}"
-    tmp=(
-      "opts[${(@)^opts[(I)${pre[1]}[$uns]]}]"
-      "dopts[${(@)^dopts[(I)${pre[1]}[$uns]]}]"
-      "odopts[${(@)^odopts[(I)${pre[1]}[$uns](|=)]}]"
-    )
-    (( $#tmp )) && unset "$tmp[@]"
+    if [[ -n "$uns" ]]; then
+      tmp=(
+        "opts[${(@)^opts[(I)${pre[1]}[$uns]]}]"
+        "dopts[${(@)^dopts[(I)${pre[1]}[$uns]]}]"
+        "odopts[${(@)^odopts[(I)${pre[1]}[$uns](|=)]}]"
+        "xors[${(@)^xors[(I)${pre[1]}[$uns]]}]"
+      )
+      odescr=( "${(@)odescr:#${pre[1]}[$uns]:*}" )
+      (( $#tmp )) && unset "$tmp[@]"
+    fi
   fi
 
   # If we aren't in an argument directly after a option name, all option
@@ -740,7 +748,7 @@ while true; do
       options=( "${(@kv)_options}" )
       state="${${action[3,-1]##[ 	]#}%%[ 	]#}"
       compstate[restore]=''
-      return 300
+      aret=yes
     else
       if [[ "${(t)line}" != *local* ]]; then
         local line
@@ -799,7 +807,7 @@ while true; do
   # Probably add the option names.
 
   if [[ -n "$opt" &&
-        ( nm -eq compstate[nmatches] ||
+        ( ( nm -eq compstate[nmatches] && -z "$aret" ) ||
           -z "$compconfig[option_prefix]" || 
           "$compconfig[option_prefix]" = *\!${cmd}* ||
           "$PREFIX" = [-+]* ) ]]; then
@@ -882,6 +890,8 @@ while true; do
   break
 done
 
+[[ -n "$aret" ]] && return 300
+
 # Set the return value.
 
 [[ nm -ne "$compstate[nmatches]" ]]
diff --git a/Completion/Linux/_rpm b/Completion/Linux/_rpm
index a6625dd2e..a22da2e4c 100644
--- a/Completion/Linux/_rpm
+++ b/Completion/Linux/_rpm
@@ -50,21 +50,26 @@ state=''
 
 # Do simple completions or get the first state.
 
-_arguments \
+_arguments -s \
   '--rcfile:resource file:_files' \
   '--ftpproxy:FTP proxy server:_hosts' \
   '--ftpport:FTP port number:' \
   '-q:*:query:->query' \
-  -{V,v,vv,y,-{setperms,setugids,querytags,initdb,showrc}} \
-  '-pipe:*:pipe command:_command_names -e' \
+  '*-v' \
+  -{V,y,-{setperms,setugids,querytags,initdb,showrc}} \
+  '-pipe:pipe command:_command_names -e' \
   '--verify:*:verify:->verify' \
-  -{i,-install}':*:install:->install' \
-  -{U,-upgrade}':*:upgrade:->upgrade' \
-  -{e,-erase}':*:uninstall:->uninstall' \
+  '-i+:*:install:->install' \
+  '--install:*:install:->install' \
+  '-U+:*:upgrade:->upgrade' \
+  '--upgrade:*:upgrade:->upgrade' \
+  '-e+:*:uninstall:->uninstall' \
+  '--erase:*:uninstall:->uninstall' \
   -'b+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_b' \
   -'t+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_t' \
   --{rebuild,rmsource,recompile,resign,addsign}':*:RPM package:->package' \
-  -{K,-checksig}':*:sigcheck:->sigcheck' \
+  '-K+:*:sigcheck:->sigcheck' \
+  '--checksig:*:sigcheck:->sigcheck' \
   '--rebuilddb:*:rebuild:->rebuild' && ret=0
 
 # As long as we have a state name...
@@ -85,8 +90,8 @@ while [[ -n "$state" ]]; do
 
   case "$lstate" in
   query)
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -101,8 +106,8 @@ while [[ -n "$state" ]]; do
       '*:RPM package:->package_or_file' && ret=0
     ;;
   verify)
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -112,11 +117,13 @@ while [[ -n "$state" ]]; do
       '*:RPM package:->package' && ret=0
     ;;
   upgrade)
-    tmp=( --oldpackage )
+    tmp=( -U --oldpackage )
     ;&
   install)
-    _arguments "$tmp[@]" \
-      -{v,vv} \
+    (( $#tmp )) || tmp=(-i)
+#set -x
+    _arguments -s "$tmp[@]" \
+      '*-v' \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -128,8 +135,8 @@ while [[ -n "$state" ]]; do
       '*:pkg file:->package_file' && ret=0
     ;;
   uninstall)
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' -e \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -144,8 +151,8 @@ while [[ -n "$state" ]]; do
   build_t)
     (( $#tmp )) || tmp=( '*:tar file:_files -g \*.\(\#i\)tar\(.\*\|\)' )
 
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -156,8 +163,8 @@ while [[ -n "$state" ]]; do
       '--timecheck:time check (seconds):' "$tmp[1]" && ret=0
     ;;
   sigcheck)
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' -K \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -165,8 +172,8 @@ while [[ -n "$state" ]]; do
       '*:RPM package file:->package_or_file' && ret=0
     ;;
   rebuild)
-    _arguments \
-      -{v,vv} \
+    _arguments -s \
+      '*-v' \
       '--rcfile:resource file:_files' \
       '--ftpproxy:FTP proxy server:_hosts' \
       '--ftpport:FTP port number:' \
@@ -185,7 +192,8 @@ while [[ -n "$state" ]]; do
     if compset -P ftp:; then
       _hosts -S/ && ret=0
     else
-      _files -g '*.(#i)rpm' && ret=0
+      _description expl 'RPM package file'
+      _files "$expl[@]" -g '*.(#i)rpm' && ret=0
     fi
     ;;
   tags)