about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-07-19 14:26:14 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-07-19 14:26:14 +0000
commitd6d4a3abfc84f0940e663cd69537789a039a7056 (patch)
tree5f5f40ae248c17c34fccbcadef85dddd4136b781 /Completion
parent1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1 (diff)
downloadzsh-d6d4a3abfc84f0940e663cd69537789a039a7056.tar.gz
zsh-d6d4a3abfc84f0940e663cd69537789a039a7056.tar.xz
zsh-d6d4a3abfc84f0940e663cd69537789a039a7056.zip
zsh-3.1.6-test-2 zsh-3.1.6-test-2
Diffstat (limited to 'Completion')
-rw-r--r--Completion/.cvsignore1
-rw-r--r--Completion/.distfiles2
-rw-r--r--Completion/Base/_brace_parameter2
-rw-r--r--Completion/Core/_path_files38
-rw-r--r--Completion/User/.distfiles6
-rw-r--r--Completion/User/_gdb50
-rw-r--r--Completion/User/_hosts2
-rw-r--r--Completion/User/_make2
-rw-r--r--Completion/User/_rlogin2
-rw-r--r--Completion/User/_sh8
-rw-r--r--Completion/User/_su22
-rw-r--r--Completion/User/_x_options5
12 files changed, 118 insertions, 22 deletions
diff --git a/Completion/.cvsignore b/Completion/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/Completion/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/Completion/.distfiles b/Completion/.distfiles
index e85e122ef..f1e1c87b3 100644
--- a/Completion/.distfiles
+++ b/Completion/.distfiles
@@ -1,3 +1,3 @@
 DISTFILES_SRC='
-    .distfiles README Makefile.in
+    .cvsignore .distfiles README Makefile.in
 '
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter
index 5993aecba..020dc81e9 100644
--- a/Completion/Base/_brace_parameter
+++ b/Completion/Base/_brace_parameter
@@ -18,4 +18,4 @@ q=${(M)lp%%\"#}
 
 [[ n -gt 0 ]] && suf=''
 
-_parameters -s "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/'
+_parameters -Qs "${q[1,-n-1]}" -S "$suf" -r '-:?#%+=[/'
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index e65f814e1..019e3abcf 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -244,7 +244,7 @@ for prepath in "$prepaths[@]"; do
  	if [[ "$tmp2[1]" = */* ]]; then
 	  tmp2=( "${(@)tmp2#${prepath}${realpath}}" )
 	  if [[ "$tmp2[1]" = */* ]]; then
-	    exppaths=( "$exppaths[@]" ${^tmp2:h}/${tpre}${tsuf} )
+	    exppaths=( "$exppaths[@]" ${^tmp2:h:q}/${tpre}${tsuf} )
           else
 	    exppaths=( "$exppaths[@]" ${tpre}${tsuf} )
 	  fi
@@ -252,6 +252,18 @@ for prepath in "$prepaths[@]"; do
         continue 2
       fi
     elif (( ! $#tmp1 )); then
+      # A little extra hack: if we were completing `foo/<TAB>' and `foo'
+      # contains no files, this will normally produce no matches and other
+      # completers might think that's it's their time now. But if the next
+      # completer is _correct or something like that, this will result in
+      # an attempt to correct a valid directory name. So we just add the
+      # original string in such a case so that the command line doesn't 
+      # change but other completers still think there are matches.
+
+      if [[ -z "$tpre$tsuf" && "$pre" = */ && -z "$suf" ]]; then
+        compadd -nQS '' - "$linepath$donepath$orig"
+        tmp4=-
+      fi
       continue 2
     fi
 
@@ -310,33 +322,33 @@ for prepath in "$prepaths[@]"; do
       if [[ -n $menu ]]; then
         [[ -n "$compconfig[path_cursor]" ]] && compstate[to_end]=''
         if [[ "$tmp3" = */* ]]; then
-	  compadd -Uf -p "$linepath$testpath" -s "/${tmp3#*/}" \
+	  compadd -QUf -p "$linepath${testpath:q}" -s "/${tmp3#*/}" \
 	          -W "$prepath$realpath$testpath" "$ignore[@]" \
 		  "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \
 		  "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-		  - "${(@)tmp1%%/*}"
+		  - "${(@)${(@)tmp1%%/*}:q}"
 	else
-	  compadd -Uf -p "$linepath$testpath" \
+	  compadd -QUf -p "$linepath${testpath:q}" \
 	          -W "$prepath$realpath$testpath" "$ignore[@]" \
 		   "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
 		   "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-		   - "$tmp1[@]"
+		   - "${(@)tmp1:q}"
 	fi
       else
         if [[ "$tmp3" = */* ]]; then
           for i in "$tmp1[@]"; do
-	    compadd -Uf -p "$linepath$testpath" -s "/${i#*/}" \
+	    compadd -QUf -p "$linepath${testpath:q}" -s "/${${i#*/}:q}" \
 		    -W "$prepath$realpath$testpath" "$ignore[@]" \
 		    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \
 		    "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-		    - "${i%%/*}"
+		    - "${${i%%/*}:q}"
 	  done
         else
-	  compadd -Uf -p "$linepath$testpath" \
+	  compadd -QUf -p "$linepath${testpath:q}" \
 		  -W "$prepath$realpath$testpath" "$ignore[@]" \
 		  "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
 		  "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-		  - "$tmp1[@]"
+		  - "${(@)tmp1:q}"
         fi
       fi
       tmp4=-
@@ -361,11 +373,11 @@ for prepath in "$prepaths[@]"; do
   done
 
   if [[ -z "$tmp4" ]]; then
-    compadd -Uf -p "$linepath$testpath" \
+    compadd -QUf -p "$linepath${testpath:q}" \
 	    -W "$prepath$realpath$testpath" "$ignore[@]" \
 	    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
 	    "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-	    - "$tmp1[@]"
+	    - "${(@)tmp1:q}"
   fi
 done
 
@@ -376,9 +388,9 @@ done
 exppaths=( "${(@)exppaths:#$orig}" )
 
 if [[ -n "$compconfig[path_expand]" &&
-      $#exppaths -eq 1 && nm -eq compstate[nmatches] ]]; then
+      $#exppaths -gt 0 && nm -eq compstate[nmatches] ]]; then
   compadd -QU -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \
-          -M 'r:|/=* r:|=*' -p "$linepath" - "${(@)exppaths}"
+          -M 'r:|/=* r:|=*' -p "$linepath" - "$exppaths[@]"
 fi
 
 [[ nm -ne compstate[nmatches] ]]
diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles
index c96f2ba3e..9187fa520 100644
--- a/Completion/User/.distfiles
+++ b/Completion/User/.distfiles
@@ -1,6 +1,8 @@
 DISTFILES_SRC='
     .distfiles
-    _a2ps _chown _compress _configure _dd _dvi _find _groups _gunzip _gzip
-    _hosts _use_lo _make _man _mh _pdf _ps _rcs _rlogin _strip _stty
+    _a2ps _chown _compress _configure _dd _dvi _find
+    _gdb _groups _gunzip _gzip
+    _hosts _use_lo _make _man _mh _pdf _ps
+    _rcs _rlogin _sh _strip _stty _su
     _tar _tar_archive _tex _uncompress _x_options _xfig 
 '
diff --git a/Completion/User/_gdb b/Completion/User/_gdb
new file mode 100644
index 000000000..ff54e6a07
--- /dev/null
+++ b/Completion/User/_gdb
@@ -0,0 +1,50 @@
+#compdef gdb
+
+# This uses the configuration keys `ps_args' and `ps_listargs'
+# described in the `_wait' function.
+
+local cur="$words[CURRENT]" prev w list ret=1
+
+_long_options -t '*=(CORE|SYM)FILE'	'_files' \
+		 '*=EXECFILE'   	'_files *(*)' \
+		 '*=TTY'		'compadd /dev/tty*' && return 0
+
+if compset -P '-(cd|directory)='; then
+  _files -/
+elif compset -P '-tty='; then
+  compadd - /dev/tty*
+elif compset -P '-(exec|se)='; then
+  _files -/g '*(*)'
+elif compset -P '-(symbols|core|command)='; then
+  _files
+elif compset -P -; then
+  compadd -QS '' - symbols\= exec\= se\= core\= command\= directory\= \
+	           cd\= tty\=
+  compadd - help h s e c x d nx n quiet q batch fullname f b
+else
+  prev="$words[CURRENT-1]"
+
+  case "$prev" in
+  (-d) _files -/ && return 0 ;;
+  (-e) _files -/g '*(*)' && return 0 ;;
+  (-[csx]) _files && return 0 ;;
+  (-b) compadd -V baud 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
+                       9600 19200 38400 57600 115200 230400 && return 0 ;;
+  esac
+  w=( "${(@)words[2,-1]}" )
+  while [[ "$w[1]" = -* ]]; do
+    [[ "$w[1]" = -[decsxb] ]] && shift 1 w
+    shift 1 w
+  done
+
+  if [[ $#w -gt 1 ]]; then
+    _files && ret=0
+    list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${compconfig[ps_listargs]:-$compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${w[1]:t}}}
+")
+    compadd -y list - ${${${(M)${(f)"$(ps $compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
+
+    return ret
+  else
+    _files -/g '*(*)'
+  fi
+fi
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index a0aca0a62..d498425bc 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -2,4 +2,4 @@
 
 : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
 
-compgen -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -k hosts
+compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" - "$hosts[@]"
diff --git a/Completion/User/_make b/Completion/User/_make
index add58dbf0..7a19484f0 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -19,6 +19,6 @@ else
   fi
 
   [[ -n "$file" ]] &&
-    compadd - $(awk '/^[a-zA-Z0-9][^/ 	]+:/ {print $1}' FS=: $file) && ret=0
+    compadd - $(awk '/^[a-zA-Z0-9][^\/ 	]+:/ {print $1}' FS=: $file) && ret=0
   (( ret )) && _files
 fi
diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin
index b792ba0d1..36ee7ffe8 100644
--- a/Completion/User/_rlogin
+++ b/Completion/User/_rlogin
@@ -1,7 +1,7 @@
 #compdef rlogin rsh ssh
 
 if [[ CURRENT -eq 2 ]]; then
-  compgen -k hosts
+  _hosts
 elif [[ CURRENT -eq 3 ]]; then
   compadd - -l
 else
diff --git a/Completion/User/_sh b/Completion/User/_sh
new file mode 100644
index 000000000..ea0fcfc11
--- /dev/null
+++ b/Completion/User/_sh
@@ -0,0 +1,8 @@
+#compdef sh ksh bash zsh csh tcsh rc
+
+if (( CURRENT == ${words[(i)-c]} + 1 )); then
+  compset -q
+  _normal
+else
+  _default
+fi
diff --git a/Completion/User/_su b/Completion/User/_su
new file mode 100644
index 000000000..e5bf09d80
--- /dev/null
+++ b/Completion/User/_su
@@ -0,0 +1,22 @@
+#compdef su
+
+local shell comp name usr base
+
+[[ $words[2] != - ]]
+(( base=$?+2 ))
+
+if [[ CURRENT -eq base ]]; then
+  compgen -u && return
+  usr=root
+elif [[ CURRENT -ge base+1 ]]; then
+  usr=$words[base]
+else
+  return
+fi
+
+shell=${"$(egrep "^$usr:" </etc/passwd)"##*:}
+compset -n $base
+for name in $shell $shell:t -default-; do
+  comp="$_comps[$name]"
+  [[ ! -z "$comp" ]] && "$comp" && return
+done  
diff --git a/Completion/User/_x_options b/Completion/User/_x_options
index a9c18b0d1..fddec2af4 100644
--- a/Completion/User/_x_options
+++ b/Completion/User/_x_options
@@ -3,7 +3,8 @@
 # A simple pattern completion, just as an example.
 
 if [ "$words[CURRENT-1]" = "-display" ]; then
-  compgen -k hosts -S':0'
+  _compskip=''
+  _hosts -S :0
 else
-  compadd -J options - -display -name -xrm
+  compadd -P- -J options - display name xrm
 fi