2013-03-23 11:49:52 -05:00
|
|
|
_su_module()
|
|
|
|
{
|
|
|
|
local cur prev OPTS
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
case $prev in
|
|
|
|
'-'|'-u'|'--user')
|
|
|
|
COMPREPLY=( $(compgen -u -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'-g'|'--group'|'-G'|'--supp-group')
|
|
|
|
COMPREPLY=( $(compgen -g -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'-s'|'--shell')
|
|
|
|
COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2013-04-07 03:12:04 -05:00
|
|
|
'-h'|'--help'|'-V'|'--version')
|
|
|
|
return 0
|
|
|
|
;;
|
2013-03-23 11:49:52 -05:00
|
|
|
esac
|
|
|
|
case $cur in
|
|
|
|
-*)
|
2013-04-07 03:12:08 -05:00
|
|
|
OPTS=" --user
|
|
|
|
--preserve-environment
|
|
|
|
--group
|
|
|
|
--supp-group
|
|
|
|
--login
|
|
|
|
--command
|
2013-03-23 11:49:52 -05:00
|
|
|
--session-command
|
2013-04-07 03:12:08 -05:00
|
|
|
--fast
|
|
|
|
--shell
|
|
|
|
--help
|
|
|
|
--version"
|
2013-03-23 11:49:52 -05:00
|
|
|
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2013-09-30 08:49:00 -05:00
|
|
|
local IFS=$'\n'
|
2013-03-23 11:49:52 -05:00
|
|
|
compopt -o filenames
|
|
|
|
COMPREPLY=( $(compgen -f -- $cur) )
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
complete -F _su_module su
|
|
|
|
complete -F _su_module runuser
|