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

Re: PATCH: completions for su and implicit fg/bg



Sven Wischnowsky wrote:
> Peter Stephenson wrote:
> > I think the code in _first was deliberately left commented because it gets
> > run every time, but the impact of this change is minimal.
> 
> Right. And since we only want it in command position, we should
> probably put it in _command_names.

Yes, of course that's the right place.  This patch moves it there.
Also, the obvious way of getting the shell is from $SHELL, so I added that
to _su.

> It's `compset -q' -- and with that I can repeat the question I asked
> at the time when I sent the completion-quoting-patch: currently the
> `-q' option only has an effect if the word on the command line is
> quoted -- should we change it to work on unquoted strings, too?

Presumably the answer should be yes, for consistency.  I already gave an
example with backslashing where it should be treated that way.

> And: nothing against giving _normal (an) optional argument(s) that
> will be put at the front of $words. (_normal is one of the older
> functions that survived (with changes) the transition from reporting
> command line words as positional parameters to the $words array we
> have now; that's why nobody made it accept arguments again, I think).

Sounds reasonable, but I haven't looked at this.

--- Completion/Base/_command_names.cn	Tue Apr 13 09:37:36 1999
+++ Completion/Base/_command_names	Fri Jul  9 14:27:33 1999
@@ -2,6 +2,13 @@
 
 local nm=$compstate[nmatches] ret=1
 
+
+# Complete jobs in implicit fg and bg
+if [[ "$PREFIX[1]" = "%" ]]; then
+  compgen -j -P '%'
+  [[ nm -ne compstate[nmatches] ]] && return
+fi
+
 compgen -c && ret=0
 
 if [[ nm -eq compstate[nmatches] ]]; then
--- Completion/Base/_first.cn	Fri Jul  9 12:04:39 1999
+++ Completion/Base/_first	Fri Jul  9 14:26:33 1999
@@ -61,8 +61,3 @@
 #         (( i++ ))
 #       done
 #     fi
-
-# Complete jobs in implicit fg and bg
-if [[ "$CURRENT" = 1 && "$PREFIX[1]" = "%" ]]; then
-  compgen -j -P '%'
-fi
--- Completion/User/_su.cn	Fri Jul  9 14:28:48 1999
+++ Completion/User/_su	Fri Jul  9 14:30:28 1999
@@ -14,7 +14,7 @@
   return
 fi
 
-shell=${"$(egrep "^$usr:" </etc/passwd)"##*:}
+shell=${SHELL:-"$(egrep "^$usr:" </etc/passwd)"##*:}
 compset -n $base
 for name in $shell $shell:t -default-; do
   comp="$_comps[$name]"

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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