diff --git a/completions/useradd b/completions/useradd index 33c41c60f6a..4216e71d353 100644 --- a/completions/useradd +++ b/completions/useradd @@ -24,7 +24,8 @@ _useradd() return 0 ;; -G|--groups) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) return 0 ;; -s|--shell) diff --git a/completions/usermod b/completions/usermod index f8cd9e0e5d7..8999c6feac7 100644 --- a/completions/usermod +++ b/completions/usermod @@ -20,7 +20,8 @@ _usermod() return 0 ;; -G|--groups) - COMPREPLY=( $( compgen -g -- "$cur" ) ) + local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) return 0 ;; -s|--shell)