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

Re: sudo autocompletion



On 10 Feb 2020, at 16:05, Andrey Butirsky <butirsky@xxxxxxxxx> wrote:
> Didn't see all the file, but probably 'su' and variants need something similar also?
> One of the "solutions"...:
> zstyle ":completion:*:$i:*" environ PATH="$SUDO_PATH"

FYI, _su doesn't currently support the environ style, so that isn't actually
doing anything for it.

I don't think using environ is a good idea for us. It'd update PATH just like
command-path ultimately does, but it happens sooner, it exports the change,
and because it supports multiple var=value pairs we'd have to do some weird
accounting to provide a default without ruining completion if someone uses it
to set HOME or whatever.

I think you're right that we probably need to do something for su and doas
too, though. I very rarely use them so i'd have to double-check how they
actually handle PATH

On 10 Feb 2020, at 13:20, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Might the user have set the command-path style in this context to
> an empty value (zero strings, which would count as false)? ...
> Could this style setting shadow a style the user had set explicitly?

Yes and yes. The first is easily fixed, but the second is weird due to how
zstyle weights patterns. That's an issue with cache-policy as well

On 10 Feb 2020, at 13:20, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 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.

That seems like it'd work. We could also give _command_names an option to do
it for us, similar to what we did recently with _normal. Both are API changes,
though, so we'd be stuck with it. Have to think about it

dana



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