DESCRIPTION

    Bash allows completion to come from various sources. The simplest is
    from a list of words (-W):

     % complete -W "one two three four" somecmd
     % somecmd t<Tab>
     two  three

    Another source is from a bash function (-F). The function will receive
    input in two variables: COMP_WORDS (array, command-line chopped into
    words) and COMP_CWORD (integer, index to the array of words indicating
    the cursor position). It must set an array variable COMPREPLY that
    contains the list of possible completion:

     % _foo()
     {
       local cur
       COMPREPLY=()
       cur=${COMP_WORDS[COMP_CWORD]}
       COMPREPLY=($( compgen -W '--help --verbose --version' -- $cur ) )
     }
     % complete -F _foo foo
     % foo <Tab>
     --help  --verbose  --version

    And yet another source is an external command (including, a Perl
    script). The command receives two environment variables: COMP_LINE
    (string, raw command-line) and COMP_POINT (integer, cursor location).
    Program must split COMP_LINE into words, find the word to be completed,
    complete that, and return the list of words one per-line to STDOUT. An
    example:

     % cat foo-complete
     #!/usr/bin/perl
     use Complete::Bash qw(parse_cmdline format_completion);
     use Complete::Util qw(complete_array_elem);
     my ($words, $cword) = @{ parse_cmdline() };
     my $res = complete_array_elem(array=>[qw/--help --verbose --version/], word=>$words->[$cword]);
     print format_completion($res);
    
     % complete -C foo-complete foo
     % foo --v<Tab>
     --verbose --version

    This module provides routines for you to be doing the above.

append:SEE ALSO

    Other modules related to bash shell tab completion: Bash::Completion,
    Getopt::Complete. Term::Bash::Completion::Generator

    Programmable Completion section in Bash manual:
    https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html

