[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specify completion without name

From: Peng Yu
Subject: Re: Specify completion without name
Date: Thu, 5 Jan 2012 10:33:13 -0600

> I would envision that such a completion function would assemble its list
> of possible completions by using your read-from-a-file mechanism and
> augment the list using compgen -a/compgen -b/compgen -A function.  It
> would probably also want to handle glob patterns and expand them to
> potentially multiple completions, but that gets tricky.

I did not know that it is so simple to get the alias (compgen -a),
buildins (compgen -b) and functions (compgen -A function) as you
mentioned. Once I know these, I agree with you that bash need not
handle these internally, rather user can call these three functions
directly. But beware to clearly document these by giving working
EXAMPLE code which include these three commands (not just text
explanation without working code, by "working code" I mean code
snippet is discouraged, a complete completion function should be

BTW, as I mentioned several times the bash man favors document
maintainer rather readers. For example, the following help doesn't
help me much when I want to learn how to use compgen.

~$ help compgen
compgen: compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat]
[-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C
command] [word]
    Display the possible completions depending on the options.  Intended
    to be used from within a shell function generating possible completions.
    If the optional WORD argument is supplied, matches against WORD are

The manpage also use a reference rather than list all the options
directly. Readers have to jump to complete to understand how to use
compgen. This is also inconvenient to users.

              Generate possible completion matches for word according  to  the
              options,  which  may  be  any  option  accepted  by the complete

If you consider it repetitive to discuss the same option twice in both
compgen and complete, at least, you can expand "help compgen" to
describe all the options (merge the current description of compgen and
complete in man). Other help messages are so concise that they are not
very helpful for learning how to use them. I'd suggest change all of
them as well.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]