Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: precommand modifiers and alias sudo="sudo "
- X-seq: zsh-users 13613
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Sebastian Stark <seb-zsh@xxxxxxxxxxx>
- Subject: Re: precommand modifiers and alias sudo="sudo "
- Date: Thu, 25 Dec 2008 16:00:17 -0800
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <5FE916F5-AC66-4D8C-B86F-BB7A5A41F245@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <5FE916F5-AC66-4D8C-B86F-BB7A5A41F245@xxxxxxxxxxx>
On Wed, Dec 10, 2008 at 01:08:15PM +0100, Sebastian Stark wrote:
> I have set up an alias sudo="sudo " that enables use of aliases with sudo.
> But now precommand modifiers like "nocorrect" or "env"* stopped working.
I have a function that allows me to use aliases with sudo. It handles
things like noglob and command, but just ignores nocorrect. I don't use
env, so that's not currently handled.
alias sudo='noglob do_sudo '
function do_sudo
{
integer glob=1
local -a run
run=( command sudo )
if [[ $# -gt 1 && $1 = -u ]]; then
run+=($1 $2)
shift ; shift
fi
(($# == 0)) && 1=/bin/zsh
while (($#)); do
case "$1" in
command|exec|-) shift; break ;;
nocorrect) shift ;;
noglob) glob=0; shift ;;
*) break ;;
esac
done
if ((glob)); then
PATH="/sbin:/usr/sbin:/usr/local/sbin:$PATH" $run $~==*
else
PATH="/sbin:/usr/sbin:/usr/local/sbin:$PATH" $run $==*
fi
}
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author