有:未找到命令

有:未找到命令

我已经创建了自己的操作系统。每当我打开 bash 并登录到子 shell 时,都会收到以下错误

-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found

它会显示多次。为了调试它,我执行了以下命令:

bash --login -x

输出:

+ source /etc/locale.conf
++ LANG=en_US.UTF-8
+ for f in '/etc/bash_completion.d/*'
+ '[' -e /etc/bash_completion.d/grub ']'
+ source /etc/bash_completion.d/grub
+++ echo grub-set-default
+++ sed s,x,x,
++ __grub_set_default_program=grub-set-default
++ have grub-set-default
bash: have: command not found
++ unset __grub_set_default_program
+++ sed s,x,x,
+++ echo grub-reboot
++ __grub_reboot_program=grub-reboot
++ have grub-reboot
bash: have: command not found
++ unset __grub_reboot_program
+++ echo grub-editenv
+++ sed s,x,x,
++ __grub_editenv_program=grub-editenv
++ have grub-editenv
bash: have: command not found

输出太长,无法粘贴到此处。但这个片段显示了错误。错误在/etc/bash_completion.d/grub文件中。该文件正在调用have.重新安装 grub 并没有修复该错误。那么,我该如何解决这个错误呢?

答案1

看来您的 Linux 中缺少 bash 补全。

另请参阅这篇文章用于 bash 补全的“have”关键字

答案2

更新我的 Debian 服务器后遇到问题:

bigbear3001@server:/etc/openvpn$ sudo su -
-su: have: command not found
-su: have: command not found
...

我通过在最后注释掉 /usr/share/bash-completion/bash_completion 中的以下行来修复它

unset -f have
unset have

have当然,您也可以使用而不是修复所有脚本_have

答案3

我安装后也遇到同样的问题git 补全。通过注释这些字符串解决了问题.bashrc:

#Git completion script
#for file in /etc/bash_completion.d/* ; do 
#       source "$file"
#done

所以,现在它工作清楚了:

user@linux~>

和不

 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found
 have: command not found

相关内容