From ba6538637ee5306790ebcfabe3261bcf37d73aef Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 18 Aug 2017 12:54:18 +0200 Subject: 41560: cleanup chsh completion for different platforms --- Completion/Unix/Command/_chsh | 97 +++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 35 deletions(-) (limited to 'Completion/Unix/Command/_chsh') diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh index 97552e3ac..006aa82a1 100644 --- a/Completion/Unix/Command/_chsh +++ b/Completion/Unix/Command/_chsh @@ -1,40 +1,67 @@ #compdef chsh chpass + +local variant help=h +local -a args shells + case $OSTYPE in -(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+)"$(