当我切换 shell 时 $SHELL 变量没有改变

mic*_*ael 4 bash zsh

我默认使用'zsh'。

但是当我在我的 zsh shell 中时,我输入 'bash' 切换到 bash,为什么 $SHELL 变量没有改变?

在执行“screen”命令之前,我可以让 screen 使用任何 shell 吗?

zsh % screen
<the shell is zsh>

zsh % bash
bash $ screen
<the shell is still bash, can I make screen to automatically start bash here>
Run Code Online (Sandbox Code Playgroud)

gei*_*rha 8

SHELL 变量(以及一些其他变量,例如 HOME 和 USER)由您登录的进程设置。它被设置为在 passwd 数据库 (/etc/passwd) 中设置的登录 shell 值。它并不意味着反映您当前使用的外壳。

screen 使用 SHELL 变量来确定在屏幕内运行的 shell,因此您可以通过运行例如覆盖它

SHELL=/bin/bash screen
Run Code Online (Sandbox Code Playgroud)

如果你想的bash是你的登录shell,而不是zsh中,您可以运行chshCH昂热SH作为用户ELL)命令。