From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3620 invoked by alias); 1 Oct 2016 14:49:52 -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: X-Seq: 39534 Received: (qmail 18698 invoked from network); 1 Oct 2016 14:49:52 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f68.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.218.68):SA:0(0.3/5.0):. Processed in 0.340896 secs); 01 Oct 2016 14:49:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: phy1729@gmail.com 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.218.68 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3eSZmpmOPoljO0pBLsK+aL6bcQkjvXSYC6AJPbRbmec=; b=nal6EUnPsx6DUiFLcX5ylTv6Ytt0kY2ri3UUMfZEiwJrlcTMKQtsEJTdRBuEvZpRhq 8imJqFdf70k0i2DqBgygoPmfxaIwJz6/0WvGc5gp+mb1Kz1PYHkmQitrTdDykglWFW1G /Z9nBEdtbE4+AYirNcUqcBK5uDzPc7DNyoKed2XPvDoWCX5qkWy3sIcxs7GhcaWMo3UC KFZ9qkUfEUKatlD2VBkY1MeuAHouxkaVpmPwB3x94AU1G34LtungD2V+wEYeVUEN9cgF Xbf6A4TJE6RlROeccwyJBZzP3BJiuEubVwtxtAUOaJQsB5SA2XDchm7STl2DeFLOlPeN /hNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=3eSZmpmOPoljO0pBLsK+aL6bcQkjvXSYC6AJPbRbmec=; b=W4b2YTlV1OJOtECQSMgW23eQ6p3fzJkDZuUL7YQfbMjJWt8p+1WriGQJ/ZYqJ1Nqbd z8OusYUH63zl6+0Nuzqaie/ex14Y782BaqUfCaZNTvhhSSdzYWYid+QRxXmt/BAq8su8 Vw4L1/7Ar1xAMaCUKsPRnk/UJZyu0lrGIWl/iWF38QZb/JBdxW/Kv3Ih8/eLK/CGDdlj f5w26zWeFlm6cl3NFYpbJb9ChPluHCehQP0ehm976/Tz0X8QhpaWWMl73kmTj24IkM3M LHnNV/qWnu6v4O5UnaQ69t1UEtp42XzJkaxNz2NMfc37MmPmED/LEC4RxY+Guerc3bCE koaw== X-Gm-Message-State: AA6/9Rl1C27RZhIk3w/yHEZmoGH93inrfNX6FLSHCTqvNSa6FxYciPWcQ7DL0Ow8xwHl/g== X-Received: by 10.157.24.103 with SMTP id t36mr1960998ott.173.1475332270457; Sat, 01 Oct 2016 07:31:10 -0700 (PDT) Date: Sat, 1 Oct 2016 09:31:06 -0500 From: Matthew Martin To: zsh-workers@zsh.org Subject: Re: PATCH: doas completion Message-ID: <20161001143106.GA11445@CptOrmolo.darkstar> Mail-Followup-To: zsh-workers@zsh.org References: <80164.1475219190@hydra.kiddle.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80164.1475219190@hydra.kiddle.eu> User-Agent: Mutt/1.6.2 (2016-07-01) On Fri, Sep 30, 2016 at 09:06:30AM +0200, Oliver Kiddle wrote: > Much of this is just cut and paste from _sudo. > I think the -a option might be OpenBSD specific: once things settle down > with a single portable doas implementation instead of the current state > of there being several then that can be cleaned up. > > Oliver > > diff --git a/Completion/Unix/Command/_doas b/Completion/Unix/Command/_doas > new file mode 100644 > index 0000000..5c26b1d > --- /dev/null > +++ b/Completion/Unix/Command/_doas > @@ -0,0 +1,18 @@ > +#compdef doas > + > +local environ e cmd > + > +zstyle -a ":completion:${curcontext}:" environ environ > + > +for e in "${environ[@]}" > +do local -x "$e" > +done > + > +cmd="$words[1]" > +_arguments -s -S \ > + '(-n -s)-C+[check config file and report on command matching]:config:_files' \ > + '(-C)-n[non-interactive: fail rather than prompt for a password]' \ > + '-a+[specify authentication style]:authentication style' \ > + '(-C)-s[run a shell]' \ > + '-u+[run command as specified user]:user:_users' \ > + '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[-u]} ) ; _normal }' I've had an alternate version sitting in my tree for a while. Merging the two I get the below. Changes are adding -A '-*' to _arguments, adding the -L option, sorting options, and ignoring * with -s. I had it in BSD, but I suppose it's been ported elsewhere now. - Matthew Martin diff --git a/Completion/BSD/Command/_doas b/Completion/BSD/Command/_doas new file mode 100644 index 0000000..b36388e --- /dev/null +++ b/Completion/Unix/Command/_doas @@ -0,0 +1,21 @@ +#compdef doas + +local environ e cmd + +zstyle -a ":completion:${curcontext}:" environ environ + +for e in "${environ[@]}" +do local -x "$e" +done + +cmd="$words[1]" +_arguments -s -S -A '-*' : \ + - optL \ + '-L[clear any persisted authorizations]' \ + - default \ + '-a+[specify authentication style]:authentication style' \ + '(-n -s)-C+[check config file and report on command matching]:config:_files' \ + '(-C)-n[non-interactive: fail rather than prompt for a password]' \ + '(-C *)-s[run a shell]' \ + '-u+[run command as specified user]:user:_users' \ + '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[-u]} ) ; _normal }'