是否有调用它的bash选项?
我发现在启动终端时使用的默认shell(使用Ctrl + Alt + T )是/bin/bash
。
并在bash
上运行内置命令type
:
type -p bash
返回结果为:
/bin/bash
当我执行Ctrl + Alt + T或说bash
时,建议运行相同的可执行文件。
这个shell与命令bash
的调用相同,它的一些选项传递给它吧? 如果是,这些选项是什么?
作为一个例子,也许传递-i
选项以使bash shell交互?
PS:也许这也是相关的,但我似乎无法拼凑所有碎片。
通常,不,终端没有通过任何选项进行bash
。 但是, bash
会假设一组默认选项,具体取决于它的调用方式。 从man bash
,部分INVOCATION
:
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.
交互式shell进一步激活其他选项。 此外,一些默认值基于调用名称( sh
vs bash
)应用。 阅读( set
部分):
-h Remember the location of commands as they are looked up for execution. This is enabled by default. -m Monitor mode. Job control is enabled. This option is on by default for interactive shells on systems that support it (see JOB CONTROL above) -B The shell performs brace expansion (see Brace Expansion above). This is on by default. -H Enable ! style history substitution. This option is on by default when the shell is interactive.
结合起来,只需在终端上调用bash
就可以启用这些选项。
您可以通过检查$-
特殊变量的值来确认:
$ echo $- himBH
可能设置的其他选项是您的终端设置为启动登录shell。 在这种情况下,终端显式传递-l
作为选项。