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

PATCH: Re: Bug with _sh completion function



On 31 Mar, Felix Rosencrantz wrote:
> There is a problem with the sh completion function.
> 
> I have a script in the cwd called Build.sh
> When I try to complete: sh -x B<TAB>
> The _sh function attempts to complete executable&builtin commands, but not
> files in the cwd.  It should be completing files in the cwd. (I don?t have dot
> in my path.)

This change makes it complete files too. Unfortunately, it further
exacerbates the situation with respect to directory completion. If you
have autocd set, they already get completed twice and with this, they
get added thrice as completions after sh.

> I'm not sure what _sh is trying to do, but it is an attempt at a completion
> function for several different shells at once.

Well, the shells all accept a command as a parameter to run so it is useful
to complete commands for them. Completion in command position was somewhat
simpler when I first added _sh.

Oliver

Index: Completion/Unix/Command/_sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_sh,v
retrieving revision 1.2
diff -u -r1.2 _sh
--- Completion/Unix/Command/_sh	28 Aug 2001 20:35:53 -0000	1.2
+++ Completion/Unix/Command/_sh	23 Apr 2003 10:43:36 -0000
@@ -16,7 +16,9 @@
   local n=${words[(b:2:i)[^-]*]}
   if (( n <= CURRENT )); then
     compset -n $n
-    _normal && return 0
+    _alternative \
+      'files:file:_files' \
+      'commands:command:_normal' && return 0
   fi
   _default
 fi



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