linux - bash 如何知道从/usr/lib/git-core/读取自动补全

标签 linux git bash shell

我安装了 git-flow,它将一些 bash 脚本复制到 /usr/lib/git-core/,现在可以在 bash complete 中使用。 我知道 bash 会读取以下目录以查找自动完成脚本:

  • /etc/bash_completion.d/
  • /usr/share/bash-completion/

是什么让 bash 知道这些新脚本? 我从 debian 存储库安装了 git-flow,我试图了解是什么让这个包运行起来。

我没有成功找到 bash 确定它需要读取此目录的位置。查看 /usr/share/bash-completion/completions/git 也无济于事。

更新

环顾四周,似乎/usr/git-core/git 和/usr/bin/git 是同一个二进制文件:

~ $ file /usr/bin/git
/usr/bin/git: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=4f634dadca99fb29ed72568d5604df087d6e6502, stripped
~ $ file /usr/lib/git-core/git
/usr/lib/git-core/git: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=4f634dadca99fb29ed72568d5604df087d6e6502, stripped

最佳答案

OK,在Etan的提示下,貌似是bash补全,其实是git补全。至于为什么 /usr/lib/git-core 是搜索,strace 显示它在配置和构建包时是硬编码的:

execve("/usr/bin/git", ["git", "help", "-a"], [/* 73 vars */]) = 0
brk(0)                                  = 0xab4000
...
openat(AT_FDCWD, "/usr/lib/git-core", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
getdents(3, /* 169 entries */, 32768)   = 6192
stat("/usr/lib/git-core/git-fetch-pack", {st_mode=S_IFREG|0755, st_size=1577256, ...}) = 0
stat("/usr/lib/git-core/git-web--browse", {st_mode=S_IFREG|0755, st_size=4398, ...}) = 0
stat("/usr/lib/git-core/git-upload-archive", {st_mode=S_IFREG|0755, st_size=1577256, ...}) = 0
stat("/usr/lib/git-core/git-credential-store", {st_mode=S_IFREG|0755, st_size=765192, ...}) = 0
...

当使用 configure --prefix=/usr/local/bin/git 从源代码编译包时,strace 日志是:

execve("/usr/local/git/bin/git", ["/usr/local/git/bin/git", "help", "-a"], [/* 73 vars */]) = 0
brk(0)                                  = 0x2395000
...
openat(AT_FDCWD, "/usr/local/git/libexec/git-core", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
getdents(3, /* 159 entries */, 32768)   = 5792
stat("/usr/local/git/libexec/git-core/git-fetch-pack", {st_mode=S_IFREG|0755, st_size=8448439, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-web--browse", {st_mode=S_IFREG|0755, st_size=4398, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-upload-archive", {st_mode=S_IFREG|0755, st_size=8448439, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-credential-store", {st_mode=S_IFREG|0755, st_size=4146627, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-p4", {st_mode=S_IFREG|0755, st_size=122122, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-merge-tree", {st_mode=S_IFREG|0755, st_size=8448439, ...}) = 0
stat("/usr/local/git/libexec/git-core/git-mergetool", {st_mode=S_IFREG|0755, st_size=8377, ...}) = 0

关于linux - bash 如何知道从/usr/lib/git-core/读取自动补全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28705593/

相关文章:

编译 linux 0.0.1 => 错误 : ‘asm’ operand has impossible constraints __asm__ ("cld\n"

javascript - 无法在 heroku 上推送 node.js 应用程序

linux - 如何使用 sed 在每个空格后添加一些文本?

c++ - 在 linux 控制台应用程序中获取给定位置的字符

linux - 用于创建指向共享库的符号链接(symbolic link)的 Bash 脚本

git - 警告 : Permanently added the RSA host key for IP address # to the list of known hosts

eclipse - java eclipse 项目的 .gitignore 文件

regex - 如何在 Perl 中用不同的随机值多次替换同一个字符串?

mysql - 在 bash shell 脚本中解析 MySQL Community Edition 5.7 自动生成的临时 root 密码

linux - rpm build .spec 更新时删除我的程序配置目录