summaryrefslogtreecommitdiffstats
path: root/completions/usermod
diff options
context:
space:
mode:
Diffstat (limited to 'completions/usermod')
-rw-r--r--completions/usermod55
1 files changed, 33 insertions, 22 deletions
diff --git a/completions/usermod b/completions/usermod
index 77ab33c..797e536 100644
--- a/completions/usermod
+++ b/completions/usermod
@@ -1,51 +1,62 @@
# usermod(8) completion -*- shell-script -*-
-_usermod()
+_comp_cmd_usermod()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# TODO: if -o/--non-unique is given, could complete on existing uids
# with -u/--uid
+ local word chroot="" has_chroot=""
+ for word in "${words[@]}"; do
+ if [[ $has_chroot ]]; then
+ chroot=$word
+ break
+ fi
+ [[ $word != -@(R|-root) ]] || has_chroot=set
+ done
+
+ local noargopts='!(-*|*[cdeflpugGRZs]*)'
+ # shellcheck disable=SC2254
case $prev in
- --comment | --home | --expiredate | --inactive | --help | --login | --password | \
- --uid | --selinux-user | -!(-*)[cdefhlpuZ])
+ --comment | --home | --expiredate | --inactive | --help | --login | \
+ --password | --uid | -${noargopts}[cdefhlpu])
+ return
+ ;;
+ --gid | -${noargopts}g)
+ _comp_compgen_gids
+ _comp_compgen -a -- -g
return
;;
- --gid | -!(-*)g)
- _gids
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
- -- "$cur"))
+ --groups | -${noargopts}G)
+ _comp_delimited , -g
return
;;
- --groups | -!(-*)G)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -g -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ --root | -${noargopts}R)
+ _comp_compgen_filedir -d
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --selinux-user | -${noargopts}Z)
+ _comp_compgen_selinux_users
return
;;
- --shell | -!(-*)s)
- _shells
+ --shell | -${noargopts}s)
+ _comp_compgen_shells "${chroot-}"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _usermod usermod
+ complete -F _comp_cmd_usermod usermod
# ex: filetype=sh