Bash shell 和 Bash 终端的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9041656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between Bash shell and Bash terminal?
提问by Gmenfan83
Ok, I hope this question makes some sense but what is the difference between a bash shell and a bash terminal? Example. When I first open up terminal I have a prompt with my current dir and my user name. In the terminal window header it says -bash- , when I type echo $SHELL I get bash. So by default the shell is bash. Where my confusion comes into play is when I type bash. My prompt then goes to bash-3.2$.Obviously it's a different mode. Are ther any major differences? I have read the man page with no answer. I understand what a bash shell is but just do not get the difference. Thanks for the clarity in advance.
好的,我希望这个问题有意义,但是 bash shell 和 bash 终端之间有什么区别?例子。当我第一次打开终端时,会提示我当前的目录和用户名。在终端窗口标题中,它说 -bash- ,当我输入 echo $SHELL 时,我得到了 bash。所以默认情况下,shell 是 bash。当我输入 bash 时,我的困惑就会发挥作用。我的提示然后转到 bash-3.2$。显然这是一种不同的模式。有什么主要区别吗?我已经阅读了手册页,但没有答案。我了解 bash shell 是什么,但只是不明白其中的区别。感谢您提前澄清。
回答by SiegeX
There is no difference, they are both instances of the bashshell.
没有区别,它们都是bashshell 的实例。
The reason you are seeing a different prompt is that your initial login shell sources ~/.bash_profilewhere presumably you have your prompt set. When you type bashit invokes another shell but because this one isn't a login shell, it doesn'tsource ~/.bash_profileand so you get the default prompt.
您看到不同提示的原因是您的初始登录 shell 源~/.bash_profile可能在其中设置了提示。当您键入bash它时,它会调用另一个 shell,但因为这不是登录 shell,所以它没有来源~/.bash_profile,因此您会得到默认提示。
If you were call bash -l, (which invokes bash as if it were a login shell) I bet you would see that your original prompt remains
如果你被调用bash -l,(它调用 bash 就像它是一个登录 shell)我敢打赌你会看到你的原始提示仍然存在

