Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sudo autocompletion
- X-seq: zsh-workers 45416
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: sudo autocompletion
- Date: Tue, 11 Feb 2020 11:12:21 +0100
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, dana <dana@xxxxxxx>
- In-reply-to: <20200210192033.1bae83dc@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <912d22db-8a8f-90f2-6738-f9f395994dcb@gmail.com> <CAN=4vMqvzUTZ7bBLcbTzi-pKAVEP1xDbq=f5pLAxmffxUjTszQ@mail.gmail.com> <1770be62-54d8-70a6-8b05-cfc98faa9b9f@gmail.com> <20200210030219.527a3ccf@tarpaulin.shahaf.local2> <ADE72275-1311-44BE-9B1D-5E617E3D9F94@gmail.com> <D0BDD1BB-192E-4D50-A0D2-0BB54388B9B9@dana.is> <20200210192033.1bae83dc@tarpaulin.shahaf.local2>
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