On 3/3/22 7:32 AM, ladyrick via Bug reports for the GNU Bourne Again SHell wrote:

Bash Version: 5.0
Patch Level: 17
Release Status: release


Description:
        I was develop a bash-completion function which can auto-complete
        history command. But when I use
        $ compgen -W "$(fc -l -10)" -- "${COMP_WORDS[1]}"
        It gave me a weird result.


        After many debug, I found that compgen will do command subtitution
        and parameter expansion in word list.

You might have saved yourself some time by reading the documentation
instead of relying on your assumptions.

      -W wordlist
              The wordlist is split using the characters  in  the  IFS
              special  variable as delimiters, and each resultant word
              is expanded.  Shell quoting is honored within  wordlist,
              in order to provide a mechanism for the words to contain
              shell metacharacters or characters in the value of  IFS.
              The  possible  completions are the members of the resul-
              tant list which match the word being completed.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to