| 1 |
_su_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS prog |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
prog="${COMP_WORDS[0]}" |
| 8 |
case $prev in |
| 9 |
'-'|'-u'|'--user') |
| 10 |
COMPREPLY=( $(compgen -u -- $cur) ) |
| 11 |
return 0 |
| 12 |
;; |
| 13 |
'-g'|'--group'|'-G'|'--supp-group') |
| 14 |
COMPREPLY=( $(compgen -g -- $cur) ) |
| 15 |
return 0 |
| 16 |
;; |
| 17 |
'-s'|'--shell') |
| 18 |
COMPREPLY=( $(compgen -W "$(command chsh -l)" -- $cur) ) |
| 19 |
return 0 |
| 20 |
;; |
| 21 |
'-h'|'--help'|'-V'|'--version') |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
esac |
| 25 |
case $cur in |
| 26 |
-*) |
| 27 |
OPTS=" --preserve-environment |
| 28 |
--whitelist-environment |
| 29 |
--group |
| 30 |
--supp-group |
| 31 |
--login |
| 32 |
--command |
| 33 |
--session-command |
| 34 |
--fast |
| 35 |
--shell |
| 36 |
--pty |
| 37 |
--no-pty |
| 38 |
--help |
| 39 |
--version" |
| 40 |
if [ "${prog}" = runuser ]; then |
| 41 |
OPTS=" ${OPTS} |
| 42 |
--user" |
| 43 |
fi |
| 44 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 45 |
return 0 |
| 46 |
;; |
| 47 |
esac |
| 48 |
local IFS=$'\n' |
| 49 |
compopt -o filenames |
| 50 |
COMPREPLY=( $(compgen -u -- $cur) ) |
| 51 |
return 0 |
| 52 |
} |
| 53 |
complete -F _su_module su |
| 54 |
complete -F _su_module runuser |