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

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



Peter Stephenson wrote:
>
> 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.

You don't want to use $SHELL. The command is run using the default shell
of the user which is su'd to. So if I type su fred -c command, then the
command will be run using fred's default shell. This is why I used
$words[base] to get the username parameter as given to su which it then
looks up in /etc/passwd.

> > And: nothing against giving _normal (an) optional argument(s) that
> > will be put at the front of $words. (_normal is one of the older
>
> Sounds reasonable, but I haven't looked at this.
 
Seeing as it's possible to stick stuff at the beginning of $words it
isn't essential to allow this to be a parameter. I suppose it will be
more readable for completions which use it though so is probably worth
doing. If you want to include it, the single line:
words=( $@ $words[@] )
added to the start of _normal should do the trick. In _su, the for loop
is just replaced by
_normal $shell
Although, you could ditch the shell variable and put the expansion after
_normal. I'll send a patch if it makes it easier.

Oliver Kiddle

P.S. Sorry Peter, you'll get this twice as I accidentally did a Reply
instead of Replyall and am now resending.



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