From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 8589f214 for ; Mon, 10 Feb 2020 19:21:23 +0000 (UTC) Received: (qmail 18423 invoked by alias); 10 Feb 2020 19:21:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45413 Received: (qmail 15539 invoked by uid 1010); 10 Feb 2020 19:21:18 -0000 X-Qmail-Scanner-Diagnostics: from wout2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25718. spamassassin: 3.4.2. Clear:RC:0(64.147.123.25):SA:0(-2.6/5.0):. Processed in 4.22541 secs); 10 Feb 2020 19:21:18 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedriedugdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkjghfofggtgfgsehtje dttdertddvnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucfkphepjeelrddukedtrdehjedrudduleenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegu rghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Date: Mon, 10 Feb 2020 19:20:33 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: sudo autocompletion Message-ID: <20200210192033.1bae83dc@tarpaulin.shahaf.local2> In-Reply-To: References: <912d22db-8a8f-90f2-6738-f9f395994dcb@gmail.com> <1770be62-54d8-70a6-8b05-cfc98faa9b9f@gmail.com> <20200210030219.527a3ccf@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 :)]