Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: sudo autocompletion



Daniel Shahaf wrote:
> dana wrote on Mon, 10 Feb 2020 11:13 -0600:
> > +  zstyle -e ":completion:${curcontext%:}:*" command-path \
> > +    'reply=( $path ${path/%\/bin//sbin} )'

I don't like it when completion functions set zstyles. I know that the
cache functions do it but even with one bad precedent I think it is
better to not proliferate the practice further. Without testing this,
I'm sceptical that the context will match at the right times - it'll
contain sudo as the command component but that may not persist.

For a solution in _sudo, the environ style is perhaps better because
that is directly where it is looked up.

> As an alternative, _sudo could set _comp_command_path=( $path
> $path/%\/bin//sbin ) and then _command_names could use that value if

We already set _comp_priv_prefix, _command_names could detect that
and adjust a local $path if it is set. That has the added advantage
of keeping the definition of the root PATH in one place rather than
repeated for doas, sudo etc. This is the sort of thing _comp_priv_prefix
was created for.

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author