使用“make install”来获取 bash_completion
这是我的 Makefile 的安装部分:
install:
for e in $(EXEC); do \
sudo cp --remove-destination ${CURDIR}/$$e /usr/local/bin; done
sudo cp ${CURDIR}/bin/stage2.d /etc/bash_completion.d/stage2
. /etc/bash_completion
其中“stage2”是我的可执行文件的名称。
最后一行是提供问题的地方。将文件添加到 bash_completion.d 目录后,我想获取 bash_completion 的源代码。但是调用 source
或 .
会产生:
. /etc/bash_completion
/etc/bash_completion: 32: [[: not found
/etc/bash_completion: 38: [[: not found
/etc/bash_completion: 50: Bad substitution
make: *** [install] Error 2
This is the install part of my Makefile:
install:
for e in $(EXEC); do \
sudo cp --remove-destination ${CURDIR}/$e /usr/local/bin; done
sudo cp ${CURDIR}/bin/stage2.d /etc/bash_completion.d/stage2
. /etc/bash_completion
Where "stage2" is the name of my executable.
The last line is what provides the issue. After adding a file into bash_completion.d
directory I want to source
the bash_completion
. But calling source
or .
yields:
. /etc/bash_completion
/etc/bash_completion: 32: [[: not found
/etc/bash_completion: 38: [[: not found
/etc/bash_completion: 50: Bad substitution
make: *** [install] Error 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看到两个问题:
Makefile
规则中使用sudo
是一个坏主意。避免这种情况,并改为调用 sudo make install 。至于解决它们:
对于 make 规则部分和
该命令的实际运行。您需要将后者记录在自述文件中,或者在
install:
目标完成后打印的行中。I see two issues:
sudo
in aMakefile
rule is a bad idea. Avoid that, and callsudo make install
instead.bash_completion
file in the non-interactive shell which is the make rule? It makes no sense.As to solving them:
for the make rule part and
for the actual running of that command. You will want to document the latter in a README, or in a line which the
install:
target prints when finished.Make 默认使用
/bin/sh
。你必须强制它使用bash,因为普通的sh
不支持[[
。gnu make 允许您[在 makefile 中]设置
SHELL
变量以强制它使用 bash。所以你需要在 makefile 的顶部添加一行
Make uses
/bin/sh
by default. you have to force it to use bash since[[
is not supported by normalsh
.gnu make lets you set
SHELL
variable [in the makefile] to force it to use bash. So you would need to add a lineat the top of your makefile