如何将非拉丁 gnu/make 目标添加到完成列表?

how to add non-latin gnu/make targets to completion list?

gnu/make 支持 makefile 中的非拉丁标识符(f.e., targets)。

示例:

$ cat GNUmakefile
test:
  @echo test
тест:
  @echo test in russian

$ make test тест
test
test in russian

但是这个例子中的bash-completion只完成了一个目标——test:

"make " + tab → "make test".

如何将非拉丁目标添加到完成列表?


在各种发行版列表(debian 5-8、ubuntu 12-15、centos 5-6、mandriva 2008)上使用不同版本的 bash 进行测试-完成.

我至少需要 bash-completion.

的最新版本支持此功能

直接的解决方案是切换到 zshoh-my-zsh 如果你想看到这个工作。

Bash 以各种错误和不受支持的功能而闻名。 zsh 工作速度快 2 倍并且几乎完全兼容 bash POSIX shell,因此您的大多数 bashrcshell 脚本将工作相同bashzsh.

的方式

我找到了解决方案。

来自文件 /usr/share/bash-completion/completions/make 的函数 _make_target_extract_script 中的错误,其中 returns sed-脚本,其中包含行:

/^[^a-zA-Z0-9]/             d             # convention for hidden tgt

删除以(特别是)非拉丁字符开头的目标。

我认为这样的正则表达式更合适(参见 this):

/^[^[[:alnum:]]]/             d             # convention for hidden tgt

如果你不能编辑/usr/share/bash-completion/completions/make,你可以添加到~/.bashrc这样的行(基于this answer):

_completion_loader make
eval "$(type _make_target_extract_script | sed '1d;s/a-zA-Z0-9/[[:alnum:]]/')"

更新

我提交 bug report(很遗憾,需要注册)。