* Re: Passing state information from one completion function to another?
@ 2000-08-15 8:31 Sven Wischnowsky
2000-08-15 8:42 ` Andrej Borsenkow
0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-08-15 8:31 UTC (permalink / raw)
To: zsh-workers
Andrej Borsenkow wrote:
> What I'd like to have is to list only my own processes in "normal" case and
> everything in case of root. This works with a single exception of sudo (and
> may be su) - in this case completion happens in current user context and does
> not know if it was root or not.
>
> Is it possible for _sudo to set some state info (notably, that we are after
> sudo at all and user name) that can be queried by other functions? Of course,
> that shoould be cleaned up after completion exits. This may be useful in other
> cases as well - some generic test "if command is to be executed as root/other
> user"
Shouldn't it be enough to use `zstyle -e' and test if $words contains
`sudo' (probably as the first word)?
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Passing state information from one completion function to another?
2000-08-15 8:31 Passing state information from one completion function to another? Sven Wischnowsky
@ 2000-08-15 8:42 ` Andrej Borsenkow
0 siblings, 0 replies; 5+ messages in thread
From: Andrej Borsenkow @ 2000-08-15 8:42 UTC (permalink / raw)
To: Sven Wischnowsky, zsh-workers
>
> Shouldn't it be enough to use `zstyle -e' and test if $words contains
> `sudo' (probably as the first word)?
>
Ehh but if I understand it correctly, in case of
sudo kill TAB
$words is modified to be just (kill), removing sudo and any of it's option? In
more general case
sudo -u foo kill TAB
it would be nice to know that we are su'ing to user foo and not to root.
The problem is, I need this information not when completing sudo but when
completing command after sudo.
-andrej
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing state information from one completion function to another?
2000-08-15 7:31 Andrej Borsenkow
@ 2000-08-15 15:44 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-08-15 15:44 UTC (permalink / raw)
To: Andrej Borsenkow, ZSH workers mailing list
On Aug 15, 11:31am, Andrej Borsenkow wrote:
} Subject: Passing state information from one completion function to another
}
} Is it possible for _sudo to set some state info (notably, that we are after
} sudo at all and user name) that can be queried by other functions?
Well, _killall (for example) uses $EUID to decide what process IDs to show.
So we can use `local -h EUID' in _sudo to make other completion functions
believe that the effective user ID has changed.
The question is, do we simply always set the local EUID to 0? Do we set it
to an EUID specified by a style? Or do we compute it somehow by parsing out
the `-u' option argument? Probably one of the latter two; parsing probably
requires adding a state for the -u option and an extra call to _arguments,
or some such.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Passing state information from one completion function to another?
@ 2000-08-15 9:13 Sven Wischnowsky
0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-08-15 9:13 UTC (permalink / raw)
To: zsh-workers
Andrej Borsenkow wrote:
> > Shouldn't it be enough to use `zstyle -e' and test if $words contains
> > `sudo' (probably as the first word)?
>
>
> Ehh but if I understand it correctly, in case of
>
> sudo kill TAB
>
> $words is modified to be just (kill), removing sudo and any of it's option? In
> more general case
>
> sudo -u foo kill TAB
>
> it would be nice to know that we are su'ing to user foo and not to root.
>
> The problem is, I need this information not when completing sudo but when
> completing command after sudo.
Ouch. Right. Would testing $BUFFER be enough?
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Passing state information from one completion function to another?
@ 2000-08-15 7:31 Andrej Borsenkow
2000-08-15 15:44 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Andrej Borsenkow @ 2000-08-15 7:31 UTC (permalink / raw)
To: ZSH workers mailing list
What I'd like to have is to list only my own processes in "normal" case and
everything in case of root. This works with a single exception of sudo (and
may be su) - in this case completion happens in current user context and does
not know if it was root or not.
Is it possible for _sudo to set some state info (notably, that we are after
sudo at all and user name) that can be queried by other functions? Of course,
that shoould be cleaned up after completion exits. This may be useful in other
cases as well - some generic test "if command is to be executed as root/other
user"
-andrej
Have a nice DOS!
B >>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-08-15 15:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-15 8:31 Passing state information from one completion function to another? Sven Wischnowsky
2000-08-15 8:42 ` Andrej Borsenkow
-- strict thread matches above, loose matches on Subject: below --
2000-08-15 9:13 Sven Wischnowsky
2000-08-15 7:31 Andrej Borsenkow
2000-08-15 15:44 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).