c875723bef
This way it's clearer to users that an argument is expected. It's likely that this commit does not catch all such cases, but it should do it for most of the affected commands I have installed.
428 lines
8.9 KiB
Bash
428 lines
8.9 KiB
Bash
# bash completion for shadow utils
|
|
|
|
have useradd &&
|
|
_useradd()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
# TODO: if -o/--non-unique is given, could complete on existing uids
|
|
# with -u/--uid
|
|
|
|
case $prev in
|
|
-c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-k|--key|\
|
|
-p|--password|-u|--uid|-Z|--selinux-user)
|
|
return 0
|
|
;;
|
|
-b|--base-dir|-d|--home|-k|--skel)
|
|
_filedir -d
|
|
return 0
|
|
;;
|
|
-g|--gid)
|
|
_gids
|
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-G|--groups)
|
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-s|--shell)
|
|
_shells
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _useradd useradd
|
|
|
|
have usermod &&
|
|
_usermod()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
# TODO: if -o/--non-unique is given, could complete on existing uids
|
|
# with -u/--uid
|
|
|
|
case $prev in
|
|
-c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\
|
|
-l|--login|-p|--password|-u|--uid|-Z|--selinux-user)
|
|
return 0
|
|
;;
|
|
-g|--gid)
|
|
_gids
|
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-G|--groups)
|
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-s|--shell)
|
|
_shells
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
# TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
} &&
|
|
complete -F _usermod usermod
|
|
|
|
have userdel &&
|
|
_userdel()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
} &&
|
|
complete -F _userdel userdel
|
|
|
|
have chage &&
|
|
_chage()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
case $prev in
|
|
-d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\
|
|
-M|--maxdays|-W|--warndays)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
} &&
|
|
complete -F _chage chage
|
|
|
|
have passwd &&
|
|
_passwd()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
case $prev in
|
|
-n|-x|-w|-i|-\?|--help|--usage)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-k -l --stdin -u -d -n -x -w -i -S \
|
|
-? --help --usage' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
_allowed_users
|
|
} &&
|
|
complete -F _passwd passwd
|
|
|
|
have chpasswd &&
|
|
_chpasswd()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
case $prev in
|
|
-c|--crypt)
|
|
COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-s|--sha-rounds)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _chpasswd chpasswd
|
|
|
|
have newusers &&
|
|
_newusers()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
case $prev in
|
|
-c|--crypt)
|
|
COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \
|
|
-- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-s|--sha-rounds)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
|
|
_filedir
|
|
} &&
|
|
complete -F _newusers newusers
|
|
|
|
have pwck &&
|
|
_pwck()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-q -r -s' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
_filedir
|
|
} &&
|
|
complete -F _pwck pwck
|
|
|
|
have groupadd &&
|
|
_groupadd()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
# TODO: if -o/--non-unique is given, could complete on existing gids
|
|
# with -g/--gid
|
|
|
|
case $prev in
|
|
-g|--gid|-K|--key|-p|--password)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _groupadd groupadd
|
|
|
|
have groupmod &&
|
|
_groupmod()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
# TODO: if -o/--non-unique is given, could complete on existing gids
|
|
# with -g/--gid
|
|
|
|
case $prev in
|
|
-g|--gid|-h|--help|-n|--new-name|-p|--password)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
|
} &&
|
|
complete -F _groupmod groupmod
|
|
|
|
complete -g groupdel
|
|
|
|
have newgrp &&
|
|
_newgrp()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
if [[ "$cur" == "-" ]]; then
|
|
COMPREPLY=( - )
|
|
else
|
|
_allowed_groups "$cur"
|
|
fi
|
|
} &&
|
|
complete -F _newgrp newgrp
|
|
|
|
have gpasswd &&
|
|
_gpasswd()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
case $prev in
|
|
-a|--add|-d|--delete|-A|--administrators|-M|--members)
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
# TODO: only -A and -M can be combined
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
|
} &&
|
|
complete -F _gpasswd gpasswd
|
|
|
|
have groupmems &&
|
|
_groupmems()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
case $prev in
|
|
-a|--add|-d|--delete)
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
-g|--group)
|
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _groupmems groupmems
|
|
|
|
have grpck &&
|
|
_grpck()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-r -s' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
|
|
_filedir
|
|
} &&
|
|
complete -F _grpck grpck
|
|
|
|
have vipw || have vigr &&
|
|
_vipw()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
case $prev in
|
|
-h|--help)
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _vipw vipw vigr
|
|
|
|
have faillog &&
|
|
_faillog()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
case $prev in
|
|
-h|--help|-l|--lock-time|-m|--maximum|-t|--time)
|
|
return 0
|
|
;;
|
|
-u|--user)
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _faillog faillog
|
|
|
|
have lastlog &&
|
|
_lastlog()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
case $prev in
|
|
-b|--before|-h|--help|-t|--time)
|
|
return 0
|
|
;;
|
|
-u|--user)
|
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
$split && return 0
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return 0
|
|
fi
|
|
} &&
|
|
complete -F _lastlog lastlog
|
|
|
|
# Local variables:
|
|
# mode: shell-script
|
|
# sh-basic-offset: 4
|
|
# sh-indent-comment: t
|
|
# indent-tabs-mode: nil
|
|
# End:
|
|
# ex: ts=4 sw=4 et filetype=sh
|