Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug#246305: zsh: completion for sudo doesn't add commands under root's path
- X-seq: zsh-workers 19862
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Bug#246305: zsh: completion for sudo doesn't add commands under root's path
- Date: Sat, 1 May 2004 05:25:46 +0000
- Cc: 246305-submitter@xxxxxxxxxxxxxxx
- In-reply-to: <20040501050229.GA11064@xxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <877jw0gzp3.wl@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20040428130449.GA3198@xxxxxxxxxxx> <1040428160206.ZM29342@xxxxxxxxxxxxxxxxxxxxxxx> <20040430122712.GA2985@xxxxxxxxxxx> <17443.1083331282@xxxxxxxxxxxxxxxxxxxxx> <20040430153937.GA4644@xxxxxxxxxxx> <1040430162512.ZM1310@xxxxxxxxxxxxxxxxxxxxxxx> <20040501050229.GA11064@xxxxxxxxxxx>
On May 1, 1:02am, Clint Adams wrote:
} Subject: Re: Bug#246305: zsh: completion for sudo doesn't add commands und
}
} This is how to achieve the equivalent effects with the patch at the
} bottom
<Nodding.>
} Should I commit?
It'd be preferable to avoid declaring "local +h" if you don't need them.
If you declare them, then zsh has to save/restore the globals, which has
the side effect of causing a rehash, etc.
So I'd suggest something like:
local -a cmdpath
if zstyle -a ":completion:${curcontext}" command-path cmdpath &&
[[ $#cmdpath -gt 0 ]]
then
local -a +h path
local -A +h commands
path=( $cmdpath ) # Resets $commands as a side-effect
fi
_alternative -O args "$defs[@]"
Remember that "local" is function-scoped, not block-scoped, so you don't
need { } around anything, nor do the local decls have to appear in the
same if-branch as the call to _alternative.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author