zsh-workers
 help / color / mirror / code / Atom feed
8233296a289d8c415419c6d2bb5210a026bc301d blob 3391 bytes (raw)

  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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
 
#compdef su

local -A opt_args
local -a args context state line expl
local first='(-)${norm}:user name:_users'
integer norm=1 strip
local shell usr

(( $words[(i)-(l|-login)] < CURRENT )) || args=( '-[use a login shell]' )
case $OSTYPE in
  linux*)
    # Some of these options only apply to util-linux, not shadow-utils
    args=( -S $args
      '(-c --command --session-command *)'{-c+,--command=}'[pass command to shell]:command string:_cmdstring'
      "(-c --command *)--session-command=[pass command to shell and don't create a new session]:command string:_cmdstring"
      '(--fast -f)'{-f,--fast}'[pass -f to shell]'
      '(-l --login -m -p --preserve-environment)'{-l,--login}'[use a login shell]'
      '(-l --login -m -p --preserve-environment)'{-m,-p,--preserve-environment}"[don't reset environment]"
      '(-s --shell)'{-s+,--shell=}'[run the specified shell]:shell:->shells'
      '(-)--help[display help information]'
      '(-)--version[display version information]'
    )
    (( $#_comp_priv_prefix || EUID == 0 )) && args+=(
      '(-g --group)'{-g+,--group=}'[specify primary group]:group:_groups'
      \*{-G+,--supp-group=}'[specify supplemental group]:group:_groups'
    )
    first="(--help --version)${first#???}"
  ;;
  *bsd*|darwin*|dragonfly*)
    args+=(
      '-f[if the invoked shell is csh, prevent it from reading .cshrc]'
      '(-m)-l[use a login shell]'
      "(-l)-m[don't reset environment]"
    )
  ;|
  *bsd*|dragonfly*)
    args+=(
      '-c+[use settings from specified login class]:class'
    )
  ;|
  freebsd*) args+=( '-s[set the MAC label]' ) ;;
  openbsd*)
    args+=(
      # See login.conf(5)
      '(-K)-a+[specify authentication type]:authentication type:(
        activ chpass crypto lchpass passwd radius reject skey snk token yubikey
      )'
      '(-a)-K[shorthand for -a passwd]'
      '-s+[run the specified shell]:shell:->shells'
      '-L[loop until login succeeds]'
    )
  ;;
  netbsd*)
    args+=(
      '-d[use a login shell but retain current directory]'
      "-K[don't use Kerberos]"
    )
  ;;
esac

if (( $words[(i)-] < CURRENT )); then
  args=( ${args:#*-(-login|l|)\[*} '1:-' )
  norm=2
fi

_arguments $args ${(e)first} "*:shell arguments:= ->rest" && return

usr=${line[norm]/--/root}
# OpenBSD supports appending a log-in method to the user name, as in usr:radius
[[ $OSTYPE == openbsd* ]] && usr=${usr%:*}

# Normal users generally don't appear in passwd on macOS; try the Directory
# Service first
if [[ $OSTYPE == darwin* ]] && (( $+commands[dscl] )); then
  shell=${"$(
    _call_program shells dscl . -read /Users/${(q)usr} UserShell
  )"#UserShell: }
fi

[[ -z $shell ]] &&
if (( ${#${(@M)args:#*-s[+\[]*:*}} && $#opt_args[(i)-(s|-shell)] )); then
  shell=${(v)opt_args[(i)-(s|-shell)]}
elif (( ${+commands[getent]} )); then
  shell="${$(_call_program shells getent passwd ${(q)usr})##*:}"
else
  shell="${${(M@)${(@f)$(</etc/passwd)}:#${usr}:*}##*:}"
fi

case $state in
  shells)
    _wanted -C $context shells expl shell compadd ${(f)^"$(</etc/shells)"}(N)
    return
  ;;
  rest)
    if [[ -z $shell || $shell = */(nologin|false) ]]; then
      _message "-s option required, $usr has no shell"
    else
      (( strip = $#words - $#line + norm ))
      (( CURRENT -= strip - 1 ))
      words[2,strip]=()
      _dispatch ${service}:${context} $shell $shell:t -default-
      return
    fi
  ;;
esac

return 1
debug log:

solving 8233296a2 ...
found 8233296a2 in https://inbox.vuxu.org/zsh-workers/5CBC1D1A-833E-4DCD-ACE1-1756A2735ECC@dana.is/
found 900905632 in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 900905632d98078142b2615a45a3b00e029ed403	Completion/Unix/Command/_su

applying [1/1] https://inbox.vuxu.org/zsh-workers/5CBC1D1A-833E-4DCD-ACE1-1756A2735ECC@dana.is/
diff --git a/Completion/Unix/Command/_su b/Completion/Unix/Command/_su
index 900905632..8233296a2 100644

Checking patch Completion/Unix/Command/_su...
Applied patch Completion/Unix/Command/_su cleanly.

index at:
100644 8233296a289d8c415419c6d2bb5210a026bc301d	Completion/Unix/Command/_su

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).