This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bash bug?: nested "bash --login -i" doesn't run /etc/profile (still runs ~/.bash_profile)


The behavior of "bash --login -i" seems to vary depending on whether
it is a "root" invocation or a nested invocation of bash.  This is
inconsistent with the description man bash, and seems to be a bug.


Details:



When bash is started using the Cygwin shortcut (which runs cygwin.bat, which executes "bash --login -i"), bash reads files /etc/profile and ~/.bash_profile. (Running "bash --login -i" from an interactive "cmd" shell does the same.)

However, when in that first bash process, another bash is started with
that same "bash --login -i" command, bash does _not_ read /etc/profile.

Interestingly, that nested bash shell _does_ still read
~/.bash_profile.

According to the bash manual page, "bash --login -i" should read
/etc/profile in either case.  (There is no mention of anything, e.g.,
an environment variable from the context of the invocation, that
changes the behavior of that command.)


An additional symptom is that the nested bash does not listen to SHELLOPTS as expected:

A root invocation notices "igncr", "verbose", and "xtrace" in the
SHELLOPTS value from its invocation environment (the Windows/cmd
environment variable) as specified--it ends up setting SHELLOPTS in
itself to a value that includes those options.

On the other hand, a nested invocation seems to ignore the SHELLOPTS
from its invocation environment (the environment variable from the
first bash shell/process)--it sets its SHELLOPTS to a value that does
_not_ include those options.)


Steps to reproduce (and easily see difference):


1. Set Windows environment variable SHELLOPTS to
   "igncr:verbose:xtrace".
2. Start bash using the installer-created Cygwin shortcut.
3. Notice (from the output from the "verbose" and "xtrace" options)
   that bash runs /etc/profile and then ~/.bash_profile.
4. Notice (from "set") that SHELLOPTS in bash includes "igncr",
   "verbose" and "xtrace" (among other options).
5. Execute "bash --login -i".
6. Notice (again, from the verbose/xtrace output) that bash does
   _not_ run /etc/profile, but still runs ~/.bash_profile.
7. Notice that SHELLOPTS in that invocation of bash does not include
   "igncr", "verbose" or "xtrace".

It seems that something is going wrong between the points at which bash
reads SHELLOPTS and runs /etc/profile and the point at which bash runs
~/.bash_profile.



Daniel







Attachment: cygcheck.out
Description: Text document

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]