2011-10-14 4 views
2

allez voir mon session:Pourquoi l'utilitaire 'script' nécessite SHELL sous Cygwin (et fonctionne bien sous Linux)?

 
    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 

Comme vous pouvez le voir premier script temps ne pas utiliser SHELL, deuxième fois et l'utiliser troisième fois l'utiliser.

Alors SHELL var env n'a pas exporté par bash ...

Pourquoi?

Est-ce droit ajouter

 
    export SHELL 

à ~/.bashrc '?

+2

Conseil: puisque la plupart d'entre nous ne parlent pas le russe, considèrent 'export LANG = C' prochaine fois avant de captures d'écran pour la capture SO :) – sehe

+0

@sehe Désolé. .. Je pensais que cette partie n'est pas si essentielle. Vous faites un travail énorme !! – gavenkoa

+0

On dirait un meilleur ajustement pour superuser.com. –

Répondre

2

Voir la réponse à ma 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. 
Questions connexes