Почему утилита 'script' требует SHELL под Cygwin (и прекрасно работает под Linux)? - PullRequest
2 голосов
/ 14 октября 2011

Посмотрите на мою сессию:

  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?

1 Ответ

2 голосов
/ 22 ноября 2011

Смотрите ответ на мой вопрос: 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.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...