这个问题可能看起来很愚蠢,但我在尝试了解如何通过 netcat 连接升级哑 shell 时遇到了这个问题。
更具体地说,我正在讨论导致特定击键在 shell 中引发特定行为的原因,例如:向上箭头 = 上一个命令,向左箭头 = 向左移动 1,清除 = 清理屏幕等...
答案1
对于 bash 来说,手册页显示:
召唤
A login shell is one whose first character of argument zero is a -, or one
started with the --login option.
An interactive shell is one started without non-option arguments (unless -s is
specified) 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 的启动文件中,您可能会看到交互性测试,如下所示:
if [ "$PS1" ]; then
# set up for interactive use
fi