Zsh Mailing List Archive
Messages sorted by:
Re: making sudo work with functions/builtins
- X-seq: zsh-users 2165
- From: Bart Schaefer <schaefer@xxxxxxxxxxx>
- To: Wayne Davison <wayne@xxxxxxxxx>
- Subject: Re: making sudo work with functions/builtins
- Date: Tue, 16 Feb 1999 21:30:03 -0800 (PST)
- Cc: Sweth Chandramouli <sweth@xxxxxxxxxxxxxxxxxxxx>, ZSH Users <zsh-users@xxxxxxxxxxxxxx>
- In-reply-to: <199902162241.OAA11943@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <19990215191509.A28737@xxxxxxxxxxxxxxxxxxxx> <199902162241.OAA11943@xxxxxxxxxxxxxxx>
- Reply-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Wayne Davison writes:
> Sweth Chandramouli writes:
> > i just had a little brainstorm about how to get around this:
> > % alias sudo='sudo cmd '
> > % cat cmd
> > #!/bin/sh
> > eval $SHELL -c \"$@\"
> While this cures the error of sudo trying to run "nocorrect", it
> does not propagate the "nocorrect" forward soon enough to turn off
> spelling corrections on the command. This delayed application is
> more of a problem with a command that has the "noglob" modifier:
> % alias e='noglob echo'
> % e f*
> % sudo e f*
> I know of no way around this problem.
Aw, sure you do. You almost got it ... all you have to do is reverse
the order of handling noglob.
case $1 in
command|exec|-) shift; break;;
nocorrect) shift; continue;;
noglob) glob=0; shift; continue;;
(($# == 0)) && 1=zsh
command sudo $~==*
command sudo $==*
alias sudo='noglob do_sudo '
However, I don't know of any equivalent way to handle nocorrect.
> It doesn't allow me to run any shell builtins or functions, though.
I don't have 3.1.5 on this laptop, so I forget the new "whence" option
for this, but I think you could test whether something was a builtin
or function, and if so cause the do_sudo or my_sudo helper function to
invoke zsh -c in such a way as to run it.
I'm not sure what builtins it would be useful to run that way, but ...
Messages sorted by: