summary refs log tree commit diff
path: root/Completion/Unix/Command/_chsh
blob: 97552e3acf88b3855f35dbccb2dadf4ed69e7c4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#compdef chsh chpass
case $OSTYPE in
(darwin*|*bsd*)
  _arguments : \
      '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
      "-l[Specify location of user]:node:" \
      "-u[Specify authentication name]:auth user:" \
      "1:user name:_users"
  ;;
(linux-gnu)
  if { =chsh -v } >&/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+)"$(</etc/shells)"})'
  _arguments : $s "1:user name:_users" --
  ;;
esac