看看我的会议:
gavenko+bash# echo $SHELL /bin/bash gavenko+bash# script Script started, file - typescript sh-4.1$ ^C sh-4.1$ exit Script started, file - typescript gavenko+bash# SHELL=/bin/bash script Script started, file - typescript gavenko+bash# ^C gavenko+bash# exit Script started, file - typescript gavenko+bash# export SHELL gavenko+bash# script Script started, file - typescript gavenko+bash# ^C gavenko+bash# exit
正如您所看到的,第一次脚本不使用SHELL,第二次使用它 第三次使用它。
所以SHELL env var不会被bash导出......
为什么?
这是正确的添加
export SHELL
到'〜/ .bashrc'?
答案 0 :(得分:2)
请参阅我的问题的答案:http://cygwin.com/ml/cygwin/2011-10/msg00269.html
This is a bug in bash which hides broken behavior in the OS. Bash expects this to be an existing environment variable, and it usually is in normal Unix like operating systems. However, bash internally sets the variable if it is missing (without exporting it): `SHELL' The full pathname to the shell is kept in this environment variable. If it is not set when the shell starts, Bash assigns to it the full pathname of the current user's login shell. It is correct not to export the variable. Bash might not be the user's shell, so it has no right to introduce itself as the SHELL to child processes.