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 d66021ee for ; Mon, 10 Feb 2020 17:14:38 +0000 (UTC) Received: (qmail 4275 invoked by alias); 10 Feb 2020 17:14:33 -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: 45410 Received: (qmail 28018 invoked by uid 1010); 10 Feb 2020 17:14:33 -0000 X-Qmail-Scanner-Diagnostics: from mail-yw1-f48.google.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(209.85.161.48):SA:0(-1.9/5.0):. Processed in 4.406663 secs); 10 Feb 2020 17:14:33 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.161.48 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MUHt59oh3Ur2Xw2XRe0e1qGu76dD48UFbvUL+Wp8grk=; b=RteZWTOOQ7VYBBoNZ4C8CnzoDSfFUmzkPGFAJLZQFMB80KOp3538XwjHoH9TqfRLBY hBEUOdQrOqoJIuRf7VlsptSFdq7LS0YAcoZTQRgV6nF+eQv/5TdAqHZk6IBMr9h9q+op dGju8E4Mf+24/yv+4zWhMr2mSNVsv4c+80DwNVbMqXfflR/ZjQwM894LMSO5o/SHLvdr ZT/AAO107zWlYptPk0n3ETx6Qs7Rr30TeAFWY+WXQ7dkVuhK8hUfRB3G7d8cyUljZAcU gK9uNy8v1hibeCQNZAxvKx/9huXqqsIWADK9tWKezDsvybUeJ4TNyZDnW37VxLAnvX6f 4d/Q== X-Gm-Message-State: APjAAAVYQzvjSc3I6Rk7kdZvhBlPcmAsKrWRIE9Wtz9i7LL+HrBS4GWA fLZJCi6XGiP6SHWThQcAAxDQ5A== X-Google-Smtp-Source: APXvYqwgARSyRH3yThw3hpqgnazHU4lz2nGSAIp5kcn84BHNe97xcakI/iiQrTuvuxgSexdSqR+3LQ== X-Received: by 2002:a0d:e745:: with SMTP id q66mr1755484ywe.503.1581354834601; Mon, 10 Feb 2020 09:13:54 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: sudo autocompletion From: dana In-Reply-To: Date: Mon, 10 Feb 2020 11:13:52 -0600 Cc: Daniel Shahaf , Zsh hackers list Content-Transfer-Encoding: quoted-printable Message-Id: References: <912d22db-8a8f-90f2-6738-f9f395994dcb@gmail.com> <1770be62-54d8-70a6-8b05-cfc98faa9b9f@gmail.com> <20200210030219.527a3ccf@tarpaulin.shahaf.local2> To: Andrey X-Mailer: Apple Mail (2.3445.104.11) On 10 Feb 2020, at 01:52, Andrey wrote: > Thanks, will try it. How about to include it in distribution by = default? Would this be too cheeky? There's not much precedent for this sort of thing (just cache-policy), = but i don't think it'd cause any issues, aside from showing too many commands = in some uncommon cases...? (Moved to -workers) dana diff --git a/Completion/Unix/Command/_sudo = b/Completion/Unix/Command/_sudo index 41e32cbae..52b212176 100644 --- a/Completion/Unix/Command/_sudo +++ b/Completion/Unix/Command/_sudo @@ -54,6 +54,18 @@ else '(-)1:command: _command_names -e' '*::arguments:{ _comp_priv_prefix=3D( $cmd -n = ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-g= roups))]} ) ; _normal }' ) + + # 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 || + zstyle -e ":completion:${curcontext%:}:*" command-path \ + 'reply=3D( $path ${path/%\/bin//sbin} )' fi =20 _arguments -s -S $args