在哪里可以找到自动完成脚本中经常使用的 _get_comp_words_by_ref 函数的文档?

aro*_*tav 5 bash autocomplete

我正在尝试为我正在开发的工具的用户编写的 bash 完成脚本编写测试(以便我可以使其与工具本身保持同步),我想知道 _get_comp_words_by_ref 到底做了什么。

样本:

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
Run Code Online (Sandbox Code Playgroud)

ric*_*ici 5

它是bash-completions包的一部分,可能安装在目录中/usr/share/bash-completion(尽管精确路径取决于发行版)。

您可以在顶级文件中bash-completion找到文档,其中包含许多实用函数。