X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0	tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SARE_SUB_ENC_UTF8
X-Spam-Check-By: sourceware.org
X-Cloudmark-SP-Filtered: true
X-Cloudmark-SP-Result: v=1.1 cv=c/XFevczzUoebyvqT+jDkQbuJdAAxuTGoZVbuGUMSf4= c=1 sm=1 a=W5crty74aesA:10 a=P4OfDokXXQoA:10 a=SV9grZ613K4A:10 a=jPJDawAOAc8A:10 a=BLceEmwcHowA:10 a=i7s4YuWtaOcA:10 a=IkcTkHD0fZMA:10 a=IaHBZPgZ0vV7m0nTkA8unw==:17 a=F0aG4L1g6yRhepjnXrMA:9 a=QEXdDO2ut3YA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
To: Oleksandr Gavenko <gavenko@bifit.com.ua>
Subject: Re: Why 'script' utility require SHELL (and work fine under  =?UTF-8?Q?Linux=29=3F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Date: Fri, 14 Oct 2011 14:47:12 -0700
From: Kaz Kylheku <kaz@kylheku.com>
Cc: <cygwin@cygwin.com>
Message-ID: <2b5085f5c029ade7accca5dcb86b6f5d@127.0.0.1>
X-Sender: kaz@kylheku.com
User-Agent: Roundcube Webmail/0.4
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com


> So SHELL env var does not exported by bash...
> Why?

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):

From "info bash".


`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.

But, in fact, the shell does not own that variable at all
and so it should not be setting it up even as an internal
variable.  The variable should stay unset to indicate
that "there does not exist a configuration for the user's
shell in this system".


Let's confirm your finding:

linux $ env | grep SHELL
SHELL=/bin/bash

cygwin $ env | grep SHELL
cygwin $ # nothing


Where does it come from on Linux? On the distro I have here,
it is not exported by anything in /etc or my /home directory.

Of course not. It comes from the "login" process which
authenticates you and fetches your shell from the password
file.

Linux man page for "login":

   The value for $HOME, $SHELL, $PATH, $LOGNAME, and
   $MAIL are  set  according to the appropriate fields in
   the password entry.

Cygwin sets HOME, and PATH, but not SHELL and LOGNAME.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

