delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/07/16:08:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 7 Mar 2004 16:08:20 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Patch for problems with profile script in Win9x [Attn: base-files maintainer]
Message-ID: <20040307210820.GC20491@redhat.com>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000501c4045d$de306640$6703a8c0 AT mtmk DOT phub DOT net DOT cable> <Pine DOT GSO DOT 4 DOT 56 DOT 0403071522080 DOT 3864 AT slinky DOT cs DOT nyu DOT edu>
Mime-Version: 1.0
In-Reply-To: <Pine.GSO.4.56.0403071522080.3864@slinky.cs.nyu.edu>
User-Agent: Mutt/1.4.1i
Reply-To: cygwin AT cygwin DOT com

On Sun, Mar 07, 2004 at 03:39:30PM -0500, Igor Pechtchanski wrote:
>On Sun, 7 Mar 2004, Paul Galbraith wrote:
>
>> It seems that the default profile script checks what shell the user is
>> running and sets appropriate defaults based on the shell.  Unfortunately, on
>> all Win9x installs that I've done recently, I've noticed that the profile
>> isn't correctly identifying that bash is my shell (which it indeed is).  The
>> problem seems to be that $0 is set to 'BASH', whereas the script is testing
>> for 'bash'.  The following changes to /etc/profile fix things up for me.
>>
>> I know that /etc/profile comes from the base-files package, but I don't know
>> where the source is located for that package...perhaps someone more
>> knowledgeable than I can submit this patch to the appropriate place?
>> Thanks!
>>
>> Paul
>
>Paul,
>
>base-files is a source-only package.  Also, this is the appropriate place
>for patches.  I'm sure the base-files maintainer reads this list.
>
>> --- /etc/profile.orig 2004-03-07 10:03:26.000000000 -0500
>> +++ /etc/profile 2004-03-07 10:24:12.000000000 -0500
>> @@ -78,7 +78,11 @@
>>  # export CVSROOT
>>
>>  # Shell dependent settings
>> -case "$0" in
>> +SHELLNAME_TMP1=`mktemp`
>> +SHELLNAME_TMP2=`mktemp`
>> +echo $0 > $SHELLNAME_TMP1
>> +tr [:upper:] [:lower:] < $SHELLNAME_TMP1 > $SHELLNAME_TMP2
>> +case `cat $SHELLNAME_TMP2` in
>>  bash     | -bash     | */bash | \
>>  bash.exe | -bash.exe | */bash.exe )
>>   # Set a HOSTNAME variable
>> @@ -122,6 +126,8 @@
>>   PS1='$ '
>>   ;;
>>  esac
>> +rm $SHELLNAME_TMP1
>> +rm $SHELLNAME_TMP2
>>
>>  export PS1
>
>FWIW, this problem has been reported before.  One of the solutions
>previously proposed for this problem was adding the various
>capitalizations of "bash" to the case, i.e.,
>
>case "$0" in
>[Bb][Aa][Ss][Hh]              | -[Bb][Aa][Ss][Hh]              | */[Bb][Aa][Ss][Hh] | \
>[Bb][Aa][Ss][Hh].[Ee][Xx][Ee] | -[Bb][Aa][Ss][Hh].[Ee][Xx][Ee] | */[Bb][Aa][Ss][Hh].[Ee][Xx][Ee] )
> # Set a HOSTNAME variable

FWIW, this solution should be faster than one that involves echo, tr,
and two pipes.

cgf

>Your solution looks cleaner, although, as Karl pointed out, it can be
>shortened to the following (also made space-in-filename friendly):
>
>case "`echo "$0" | tr [:upper:] [:lower:]`" in
>bash     | -bash     | */bash | \
>bash.exe | -bash.exe | */bash.exe )
> # Set a HOSTNAME variable

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019