当您在bash提示符下输入无效命令时,您会收到消息
-bash: {command}: command not found
什么是-
在开始的时候意味着什么?
这意味着它是一个登录shell。
来自man bash
:
登录外壳是一个参数为零的第一个字符为-的外壳程序,或以--login选项开头的外壳程序。
(在bash
术语中,“ zeroth”自变量是命令名称,在您的情况下为bash
。)bash
以此为信号来执行登录活动(例如execute.bash_profile
等)。
可以自动添加破折号的一种方法是,如果外壳以开头exec
。从Bash手册:
exec [-cl] [-a name] [command [arguments]]
[...]如果
-l
提供了该选项,则shell在传递给command的第零个参数的开头放置一个破折号。
比较这两次尝试运行命令的尝试nonexistent
。首先没有-l
:
$ exec bash
$ nonexistent
bash: nonexistent: command not found
其次,具有:
$ exec -l bash
$ nonexistent
-bash: nonexistent: command not found
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句