Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sudo autocompletion
dana wrote on Mon, 10 Feb 2020 11:13 -0600:
> +++ b/Completion/Unix/Command/_sudo
> @@ -54,6 +54,18 @@ else
> + # By default, _command_names uses the current PATH to complete commands. This
> + # doesn't necessarily make sense for sudo on systems that use its secure_path
> + # feature -- a common issue is that /**/sbin appear in secure_path but not in
> + # unprivileged users' PATHs. Ideally we could parse the correct value out of
> + # `sudo -l`, but since that requires a password it won't work half the time.
> + # To do the right thing in the most common cases, we'll simply ensure that the
> + # sbin variants always appear in the default command-path (bash-completion's
> + # _sudo does something similar)
> + zstyle -t ":completion:${curcontext}:" command-path ||
Might the user have set the command-path style in this context to
an empty value (zero strings, which would count as false)?
> + zstyle -e ":completion:${curcontext%:}:*" command-path \
> + 'reply=( $path ${path/%\/bin//sbin} )'
Could this style setting shadow a style the user had set explicitly?
(e.g., because the pattern here is more specific than the pattern the
user has set)
As an alternative, _sudo could set _comp_command_path=( $path
$path/%\/bin//sbin ) and then _command_names could use that value if
the style isn't set then. The parameter would be made local by
_main_complete. This is similar to how, say, $precommands is handled.
HTH,
Daniel
[who was going to add this to zsh-sensible, but prefers fixing this
in zsh.git if possible :)]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author