summaryrefslogtreecommitdiffstats
path: root/completions/useradd
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
commitf4acb49ea148cdd899f7f29f1591c7bc853c2135 (patch)
treeb62d60873864065d6428a84a119dd8a3c90f1397 /completions/useradd
parentAdding upstream version 1:2.11. (diff)
downloadbash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.tar.xz
bash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.zip
Adding upstream version 1:2.12.0.upstream/1%2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/useradd')
-rw-r--r--completions/useradd53
1 files changed, 32 insertions, 21 deletions
diff --git a/completions/useradd b/completions/useradd
index ceeca91..6c0bef1 100644
--- a/completions/useradd
+++ b/completions/useradd
@@ -1,46 +1,57 @@
# useradd(8) completion -*- shell-script -*-
-_useradd()
+_comp_cmd_useradd()
{
- 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='!(-*|*[cefKpubdkRgGZs]*)'
+ # shellcheck disable=SC2254
case $prev in
- --comment | --help | --expiredate | --inactive | --key | --password | --uid | \
- --selinux-user | -!(-*)[chefKpuZ])
+ --comment | --help | --expiredate | --inactive | --key | --password | \
+ --uid | -${noargopts}[chefKpu])
+ return
+ ;;
+ --base-dir | --home-dir | --skel | --root | -${noargopts}[bdkR])
+ _comp_compgen_filedir -d
return
;;
- --base-dir | --home-dir | --skel | --root | -!(-*)[bdkR])
- _filedir -d
+ --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})
+ --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
[[ $cur == -* ]] &&
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _useradd useradd
+ complete -F _comp_cmd_useradd useradd
# ex: filetype=sh