开发者

Why 'script' utility require SHELL under Cygwin (and work fine under Linux)?

Look to my session:

  gavenko+bash# echo $SHELL
  /bin/bash
  gavenko+bash# script
  Script started, file - typescript
 开发者_Python百科                                  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

As you can see first time script does not use SHELL, second time use it and third time use it.

So SHELL env var does not exported by bash...

Why?

Is this right add

  export SHELL

to '~/.bashrc'?


See answer to my question: 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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜