From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28961 invoked by alias); 17 Aug 2017 15:48:26 -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: 41560 Received: (qmail 5307 invoked by uid 1010); 17 Aug 2017 15:48:26 -0000 X-Qmail-Scanner-Diagnostics: from nm2-vm3.bullet.mail.ir2.yahoo.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(212.82.96.83):SA:0(-1.9/5.0):. Processed in 5.03886 secs); 17 Aug 2017 15:48:26 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1502984490; bh=qD5ve7KeHhsd/MidHtSAAbm0L6ptZ+mMfHCZpgrujj0=; h=From:To:Subject:Date:From:Subject; b=p3xxzZNoer9TPxQy3IHoDrErHCMB5eJwfO/MQmIP8BQOyy2huiMjRRcAyJG0pM5Rx+JAC/7EGIYjO1I2nGg9qtEK+BWMAGhmU7cUJQtPfQg/RLnFD7Z07Frj+C6/SQuuKeCRD/wwFsr+dFIYZl2ItJhCIDlNlYNVn3CCTvrsxFjPW41P7c/0ke+eyuoLSUUuyQAHoJ+ythm//kjqHjVJEdTQuA3hQN1WzEQKQKG8/FiADglUhp7PQGs1mQYQDJzhp2kNjY1vTgn8MZ8ieb6lqpcQbIw1y6/+77lk9wjZKh4CsjKafkU3mcotDE4oyy0vQOerRnsTaOj4OEIu9uVPJw== X-Yahoo-Newman-Id: 706176.24530.bm@smtp135.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: NbqIaLcVM1m8OcoyPIuelDISncvmLaCfZj7excDnn2xt04T oNqfO45AkMvOZRafBpP.LXIhPyZoiKU1qivPLkxC8ECVKzwh0oGrI8BGDKyh qs4wc.XnW_E9GyJhoNoiIa1BOMLch1FzZAtNykhT5Bm7vgN0ltVhcc9KZrRi XLgqU53jLYrKOOjQ7IVw_lNBc0P0hlTz9ysBqd4tqic2kIvZ_JMA2SXH5AHY mD_VCF0e629jVdvJfOLARDsqpxWkXSJYQYuFhjS59HVzlRp.DstpJkH8WxeQ 8yo9kPX4zi0TuZ9EbtgwASZ8ghUjrbdzGsCWKDtxNzWVYZnGBbw0euuE87Yk jO5YgCqvMz1XnmBW6MRBlEXNtYbwLYMLKUKkrE3Y.L1QmPRAI2BnbWXhaViD SNYqmlptTmA.jKdDcFIRfh8q70vF2LGjesjiVSgTpd3mIaB.UXEGANojGjzj PG1dKxmGiWUI1a9fxxjCXY1bDokaJYvqIiJGX61ziGg.l3nd8Ozpt2_JQKEI - X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: cleanup chsh completion for different platforms MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26412.1502984489.1@thecus.kiddle.eu> Date: Thu, 17 Aug 2017 17:41:29 +0200 Message-ID: <26413.1502984489@thecus.kiddle.eu> chsh is worse than most things when it comes to platform differences with there even being a variety of different implementations on Linux. This is an attempt to make it a bit more useful. Oliver diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh index 006aa82a1..97552e3ac 100644 --- a/Completion/Unix/Command/_chsh +++ b/Completion/Unix/Command/_chsh @@ -1,67 +1,40 @@ #compdef chsh chpass - -local variant help=h -local -a args shells - case $OSTYPE in - darwin*|*bsd*) - args=( '(-a)-s[specify new login shell]:shell:($shells)' ) - ;| - (free|net|open)bsd*) - args+=( '(-s 1)-a[specify user database entry]:passwd entry' ) - ;| - darwin*) - args+=( - '-l[specify location of user]:location' - '-u[specify authentication name]:auth user' - ) +(darwin*|*bsd*) + _arguments : \ + '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(&/dev/null + then + local -a opts shells + shells=( $(=chsh -l) ) + _arguments : \ + "(-)-s[Specify your login shell]:shell:($shells)" \ + "(-)--shell[Specify your login shell]:shell:($shells)" \ + "(-)-l[Print shells in /etc/shells]" \ + "(-)--list-shells[Print shells in /etc/shells]" \ + "(-)-u[Print a usage message and exit]" \ + "(-)--help[Print a usage message and exit]" \ + "(-)-v[Print version information and exit]" \ + "(-)--version[Print version information and exit]" \ + "1:user name:_users" + return + fi + # else fall through + ;& +(*) + local s='' + # Use $s to cause all options to be treated as mutually exclusive + [[ $words[CURRENT-1] = -* ]] && s="(-)$words[CURRENT-1]" + # This fiddling with $s is a hack to cause "_arguments : --" to use + # the /etc/shells listing for -s or --shell even when the description + # of that option has been pulled from the GNU --help output. + [[ $words[CURRENT-1] = (-s|--shell) ]] && + s="$s"'[ ]:shell:(${(Z+Cn+)"$(