Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Completion after commands with paths.



Peter Stephenson wrote:

> Some completion functions are too finnicky about looking at the command
> names: they should be looking at the basenames, and instead are looking at
> the full string.  The problem I had was in _ssh when I was calling scp with
> a full path; the case statement doesn't take this into account.  That's an
> easy fix, but there may be a lot of other functions with this bug (or
> issue, as we ought to call it now we have a tracking system), and I don't
> have time to look now.

There were...

Bye
 Sven

Index: Completion/Debian/_apt
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_apt,v
retrieving revision 1.1.1.21
diff -u -r1.1.1.21 _apt
--- Completion/Debian/_apt	2000/03/23 04:19:28	1.1.1.21
+++ Completion/Debian/_apt	2000/04/05 11:24:31
@@ -1,7 +1,7 @@
 #compdef apt-get apt-cache apt-cdrom apt-config
 
 _apt () {
-  case "$words[1]" in
+  case "${words[1]:t}" in
     apt-get) _apt-get "$@";;
     apt-cache) _apt-cache "$@";;
     apt-cdrom) _apt-cdrom "$@";;
Index: Completion/Debian/_bug
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_bug,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 _bug
--- Completion/Debian/_bug	1999/11/08 19:43:14	1.1.1.3
+++ Completion/Debian/_bug	2000/04/05 11:24:31
@@ -8,7 +8,7 @@
            '-v[version]' \
            '*:package:_deb_packages installed')
 
-case "$words[1]" in
+case "${words[1]:t}" in
 bug)
 _arguments '-c[exclude configs from report]' \
            '-f[argument is a file, not a package]' \
Index: Completion/Debian/_dpkg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_dpkg,v
retrieving revision 1.2
diff -u -r1.2 _dpkg
--- Completion/Debian/_dpkg	2000/04/04 19:34:26	1.2
+++ Completion/Debian/_dpkg	2000/04/05 11:24:31
@@ -20,7 +20,7 @@
            '--version[show version]' \
            '--licence[show licensing]')
 
-case "$words[1]" in
+case "${words[1]:t}" in
 dpkg)
 _arguments -s '(--install)-i[install packages]:Debian package:_files -g \*.deb' \
            '(-i)--install:Debian package:_files -g \*.deb' \
Index: Completion/User/_chown
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_chown,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 _chown
--- Completion/User/_chown	1999/08/23 10:07:36	1.1.1.3
+++ Completion/User/_chown	2000/04/05 11:24:31
@@ -1,7 +1,7 @@
 #compdef chown chgrp
 
 if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
-  if [[ $words[1] = chgrp ]] || compset -P '*[:.]'; then
+  if [[ ${words[1]:t} = chgrp ]] || compset -P '*[:.]'; then
     _groups
   else
     if [[ $OSTYPE = (solaris*|hpux*) ]]; then
Index: Completion/User/_dvi
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_dvi,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 _dvi
--- Completion/User/_dvi	2000/02/27 16:37:37	1.1.1.6
+++ Completion/User/_dvi	2000/04/05 11:24:32
@@ -9,7 +9,7 @@
   ':output DVI file:_files -g \*.\(dvi\|DVI\)'
 )
 
-case "$words[1]" in
+case "${words[1]:t}" in
 dvips)
   _arguments -s \
     '-a[make three passes]' \
Index: Completion/User/_imagemagick
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_imagemagick,v
retrieving revision 1.1
diff -u -r1.1 _imagemagick
--- Completion/User/_imagemagick	2000/04/04 14:57:34	1.1
+++ Completion/User/_imagemagick	2000/04/05 11:24:32
@@ -18,7 +18,7 @@
   return
 fi
 
-case "$words[1]" in
+case "${words[1]:t}" in
 display)
   _arguments -M 'm:{a-z}={A-Z}' \
       '*-backdrop[use full screen]' \
Index: Completion/User/_ispell
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_ispell,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 _ispell
--- Completion/User/_ispell	1999/09/13 09:49:29	1.1.1.1
+++ Completion/User/_ispell	2000/04/05 11:24:32
@@ -1,6 +1,6 @@
 #compdef ispell buildhash munchlist findaffix tryaffix icombine ijoin
 
-case "$words[1]" in
+case "${words[1]:t}" in
 ispell)
   _arguments -s \
     '(-n)-t[input file is in TeX/LaTeX format]' \
Index: Completion/User/_lp
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_lp,v
retrieving revision 1.2
diff -u -r1.2 _lp
--- Completion/User/_lp	2000/04/01 20:43:43	1.2
+++ Completion/User/_lp	2000/04/05 11:24:32
@@ -59,7 +59,7 @@
     return 1
   fi
 else
-  if [[ "$words[1]" = (lpq|lprm) ]]; then
+  if [[ "${words[1]:t}" = (lpq|lprm) ]]; then
     if [[ "$words" = *-P* ]]; then
       printer=(-P "${${words##*-P( |)}%% *}")
     else
Index: Completion/User/_mount
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mount,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 _mount
--- Completion/User/_mount	2000/03/23 04:19:30	1.1.1.8
+++ Completion/User/_mount	2000/04/05 11:24:32
@@ -368,7 +368,7 @@
   esac
 fi
 
-if [[ "$words[1]" = mount ]]; then
+if [[ "${words[1]:t}" = mount ]]; then
 
   # Here are the tests and tables for the arguments and options for
   # the `mount' program. The `fss' array has to be set to the names
Index: Completion/User/_mysql_utils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mysql_utils,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 _mysql_utils
--- Completion/User/_mysql_utils	2000/03/23 04:19:31	1.1.1.2
+++ Completion/User/_mysql_utils	2000/04/05 11:24:32
@@ -209,7 +209,7 @@
   else
     local curcontext="$curcontext"
 
-    case "$words[1]" in
+    case "${words[1]:t}" in
       (create|drop)
         _wanted mysqldbs expl "MySQL databases" _mysql_databases
       ;;
@@ -224,7 +224,7 @@
 }
 
 _mysql_utils () {
-  case "$words[1]" in
+  case "${words[1]:t}" in
     mysql)
       _mysql "$@"
     ;;
Index: Completion/User/_pbm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_pbm,v
retrieving revision 1.1.1.15
diff -u -r1.1.1.15 _pbm
--- Completion/User/_pbm	2000/03/24 00:01:57	1.1.1.15
+++ Completion/User/_pbm	2000/04/05 11:24:33
@@ -6,14 +6,14 @@
 # defaults can be overridden by simply defining completion functions
 # for those commands whose arguments you want to complete differently.
 
-local pat expl ret=1
+local pat expl ret=1 cmd="${words[1]:t}"
 
-if [[ "$words[1]" = pnm* ]]; then
+if [[ "$cmd" = pnm* ]]; then
   pat='*.(#i)p[bgp]m'
-elif [[ "$words[1]" = *top[bgpn]m ]]; then
-  pat="*.(#i)${words[1]%%top[bgpn]m}"
+elif [[ "$cmd" = *top[bgpn]m ]]; then
+  pat="*.(#i)${cmd%%top[bgpn]m}"
 else
-  pat="*.(#i)${words[1][1,3]}"
+  pat="*.(#i)${cmd[1,3]}"
 fi
   
 if [[ $# -ne 0 || $+_in_pbm -ne 0 ]]; then
@@ -24,7 +24,7 @@
 
 local _in_pbm=yes
 
-case "$words[1]" in
+case "$cmd" in
 asciitop[gn]m)
   _arguments \
     '-d[specify divisor]:divisor:' \
Index: Completion/User/_psutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_psutils,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 _psutils
--- Completion/User/_psutils	2000/02/13 03:53:37	1.1.1.1
+++ Completion/User/_psutils	2000/04/05 11:24:33
@@ -1,6 +1,6 @@
 #compdef epsffit extractres fixdlsrps fixfmps fixmacps fixpsditps fixpspps fixscribeps fixtpps fixwfwps fixwpps fixwwps includeres psbook psmerge psnup psresize psselect pstops getafm showchar
 
-case "$words[1]" in
+case "${words[1]:t}" in
 epsffit)
   _arguments \
     '-v[print version]' \
Index: Completion/User/_rcs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_rcs,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 _rcs
--- Completion/User/_rcs	2000/03/23 04:19:30	1.1.1.7
+++ Completion/User/_rcs	2000/04/05 11:24:33
@@ -1,10 +1,10 @@
 #compdef co ci rcs
 
-local nm=$compstate[nmatches]
+local nm=$compstate[nmatches] cmd="${words[1]:t}"
 
-[[ $words[1] = ci || $words[1] = rcs ]] && _files
+[[ $cmd = ci || $cmd = rcs ]] && _files
 
-if [[ $compstate[nmatches] -eq nm && -d RCS && $words[1] != ci ]]; then
+if [[ $compstate[nmatches] -eq nm && -d RCS && $cmd != ci ]]; then
   local rep expl
 
   rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//))
Index: Completion/User/_rlogin
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_rlogin,v
retrieving revision 1.1.1.17
diff -u -r1.1.1.17 _rlogin
--- Completion/User/_rlogin	2000/03/23 04:19:30	1.1.1.17
+++ Completion/User/_rlogin	2000/04/05 11:24:33
@@ -1,7 +1,7 @@
 #compdef rlogin rsh remsh rcp
 
 _rlogin () {
-  case "$words[1]" in
+  case "${words[1]:t}" in
   rlogin)
     _arguments -s \
       '-8[allow 8-Bit data]' \
Index: Completion/User/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_ssh,v
retrieving revision 1.1.1.13
diff -u -r1.1.1.13 _ssh
--- Completion/User/_ssh	2000/03/23 04:19:30	1.1.1.13
+++ Completion/User/_ssh	2000/04/05 11:24:33
@@ -14,7 +14,7 @@
 
   # ssh-opt is a pseudo-command used to complete ssh options for `scp -o'.
 
-  case "$words[1]" in
+  case "${words[1]:t}" in
   ssh|slogin)
     args=(
       ':remote host name:->userhost'
Index: Completion/User/_tiff
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_tiff,v
retrieving revision 1.3
diff -u -r1.3 _tiff
--- Completion/User/_tiff	2000/04/03 15:27:14	1.3
+++ Completion/User/_tiff	2000/04/05 11:24:33
@@ -1,9 +1,9 @@
 #compdef -P (tiff*|*2tiff|pal2rgb)
 
-local pat expl ret=1
+local pat expl ret=1 cmd="${words[1]:t}"
 
-if [[ "$words[1]" = *2tiff ]]; then
-  pat="*.(#i)${words[1]%%2tiff}"
+if [[ "$cmd" = *2tiff ]]; then
+  pat="*.(#i)${cmd%%2tiff}"
 else
   pat="*.(#i)tiff"
 fi
@@ -23,7 +23,7 @@
 local curcontext="$curcontext" state line ret=1
 typeset -A opt_args
 
-case "$words[1]" in
+case "$cmd" in
 tiff2bw)
   _arguments -C \
     '-c[specify compression scheme]:compression scheme:->compress' \
Index: Completion/User/_yp
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_yp,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 _yp
--- Completion/User/_yp	2000/03/23 04:19:31	1.1.1.7
+++ Completion/User/_yp	2000/04/05 11:24:33
@@ -14,7 +14,7 @@
   )
 fi
 
-case "$words[1]" in
+case "${words[1]:t}" in
 ypcat)
   _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0
   ;;
Index: Completion/X/_xutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/_xutils,v
retrieving revision 1.2
diff -u -r1.2 _xutils
--- Completion/X/_xutils	2000/04/01 20:43:43	1.2
+++ Completion/X/_xutils	2000/04/05 11:24:33
@@ -1,6 +1,6 @@
 #compdef xdpyinfo xwininfo xkill xfontsel xfd xev xhost xon xsetroot xwd xwud xrdb
 
-case "$words[1]" in
+case "${words[1]:t}" in
 xdpyinfo)
   _x_arguments \
     -queryExtensions \

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author