Re: [PATCH 04/10] bash-completion: login-utils

Sami Kerola
2013-04-01T16:05:06Z

On Wed, Mar 27, 2013 at 09:42:23PM -0400, Dave Reisner wrote:
> On Wed, Mar 27, 2013 at 10:07:46PM +0000, Sami Kerola wrote:
> > +++ b/shell-completion/chfn
> > @@ -0,0 +1,31 @@
> > +_chfn_module()
> > +{
> > + local cur prev OPTS
> > + COMPREPLY=()
> > + cur="${COMP_WORDS[COMP_CWORD]}"
> > + prev="${COMP_WORDS[COMP_CWORD-1]}"
> > + case $prev in
> > + '-f'|'--full-name')
> > + COMPREPLY=( $(compgen -W "name" -- $cur) )
> > + return 0
> > + ;;
> > + '-o'|'--office')
> > + COMPREPLY=( $(compgen -W "office" -- $cur) )
> > + return 0
> > + ;;
> > + '-p'|'--office-phone'|'-h'|'--home-phone')
> > + COMPREPLY=( $(compgen -W "phone-nr" -- $cur) )
> > + return 0
> > + ;;
>
> I don't understand these. Given the previous argument being one of the
> found flags, you're completing staticly defined strings. Why complete
> anything at all?

I thought giving a textual hint to user is good idea. The hint is now
gone. Some of the commands are giving similar hints, other are not. Let
see what is found to be more preferred by users and adjust accordingly.

> > + OPTS=" -u --user
> > + -m -p --preserve-environment
> > + -g --group
> > + -G --supp-group
> > + - -l --login
> > + -c --command
> > + - -c
> > + --session-command
> > + -- -c
>
> Please don't include the end of options marker in here. You appear to
> have duplicated -c as well.

Good catch, end of options marker is removed. While writing this reply I
realized that the duplicates are still in my git. Hold on I'll do rebase
fix to that.

--
Sami Kerola