Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Mon, 25 Aug 2003 18:27:07 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: mike808 cc: john DOT r DOT morrison AT ntlworld DOT com, cygwin AT cygwin DOT com Subject: Re: BUG: base-files-2.2-1 profile.d runs in subshell - sourced files fail In-Reply-To: <38320.12.22.157.254.1061853499.squirrel@mail3411.b0.com> Message-ID: References: <38320 DOT 12 DOT 22 DOT 157 DOT 254 DOT 1061853499 DOT squirrel AT mail3411 DOT b0 DOT com> Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 25 Aug 2003, mike808 wrote: > In base-files-2.2-1, the following was recently changed: > > > # Run all of the profile.d scripts > > # Note that these are supplied by separate packages > > /bin/find /etc/profile.d -iname '*.sh' -type f | while read f; do > > if [ -f "$f" ]; then > > . "$f" > > fi > > done > > Previously, the find was executed as an expanded filename wildcard > expansion as part of a 'for' loop. (c.f. 2.0-2) > > When this was changed to the current code, because a pipe is used, > the subsequent commands run in a *sub-shell* of the parent /etc/profile > script executing. This means that any environment changes performed > by the files in /etc/profile.d/ are *lost* when the sub-shell returns > to the parent. > > This effectively nullifies any environment changes being performed in > those files. Things like PATH setting, etc. I use them to clean up > environment variables mangled by Rational prior to setting up a shell > in Cygwin. > > Please put it back to the way it was in base-files-2.0-2, with > the one exception that quote marks be placed around the "$i" iterator > variable so as to preserve any whitespace that might be in the filenames. > > I have corrected that working code (from 2.0-2) below: > > > # Run all of the profile.d scripts > > # Note that these are supplied by separate packages > > for i in /etc/profile.d/*.sh ; do > > if [ -f "$i" ]; then > > . "$i" > > fi > > done > > Thank you. > Michael/ Michael, Your code above will not find the same files as what's currently in /etc/profile. The correct code (with no subshells) is included below. # Run all of the profile.d scripts # Note that these are supplied by separate packages while read f; do if [ -f "$f" ]; then . "$f" fi done << EOF `/bin/find /etc/profile.d -iname '*.sh' -type f` EOF Hope this helps, Igor P.S. While investigating this, I found that /etc/profile.d/mc.sh uses the 'alias' command which /bin/sh doesn't recognize. Pavel, please take note. -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/