bashautocomplete

Where can I find documentation for _get_comp_words_by_ref function used in autocompletion scripts?


I am trying to write tests for a bash completion script that was contributed by a user of a tool I am developing (so that I can keep it up to date with the tool itself) and I am wondering what _get_comp_words_by_ref exactly does.

Sample:

local cur prev
if type _get_comp_words_by_ref &>/dev/null ; then
    _get_comp_words_by_ref cur prev
else
    cur=$2 prev=$3
fi

Solution

  • It's part of the bash-completions package, which might be installed in the directory /usr/share/bash-completion (although the precise path depends on the distro).

    You may find the documentation in the top-level file bash-completion, which contains a number of utility functions.