delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/11/01:43:26

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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: Wed, 11 May 2005 01:42:24 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Eric Blake <ebb9 AT byu DOT net>
cc: john AT morrison DOT mine DOT nu, cygwin AT cygwin DOT com
Subject: Re: base-files patch (atn: Eric Blake)
In-Reply-To: <427F5C1C.6050202@byu.net>
Message-ID: <Pine.GSO.4.61.0505110135050.29281@slinky.cs.nyu.edu>
References: <032520051926 DOT 2104 DOT 424465D60002AFD30000083822058861720A050E040D0C079D0A AT comcast DOT net> <1492 DOT 192 DOT 168 DOT 0 DOT 12 DOT 1115538762 DOT squirrel AT mail DOT morrison DOT mine DOT nu> <427F5C1C DOT 6050202 AT byu DOT net>
MIME-Version: 1.0

On Mon, 9 May 2005, Eric Blake wrote:

> According to John Morrison on 5/8/2005 1:52 AM:
> > On Fri, March 25, 2005 8:26 pm, Eric Blake said:
> >
> >>True enough.  And that points out another bug - echo "$0" may fail if $0
> >>starts with -, it should be echo -- "$0".  Isn't portable shell
> >>programming fun?
> >
> > Sorry that this has taken so long, but I'm just getting around to adding
> > all the fixes emailed wrt /etc/profile.  I tried the above, and it broke
> > so I checked the man pages,
>
> Serves me right for thinking that echo was standard when I typed my
> original message, rather than me actually testing at the command line.
> Yes indeed, POSIX requires that echo must interpret -- as a string
> operand, rather than the standard interpretation of being an argument
> separator.
>
> > so, I'm afraid that echo -- "${0}" won't work.
>
> This will work instead:
> case `printf %s "$0" | /usr/bin/tr '[:upper:]' '[:lower:]'` in
> bash | -bash | */bash )
> [..]

Or, of course, the standard "portable scripting" trick:

case "`echo "_$0" | /usr/bin/tr '[:upper:]' '[:lower:]'`" in
_bash | _-bash | _*/bash )
[..]

(or, if you don't mind a slightly longer command:
case "`echo "_$0" | /usr/bin/tr '[:upper:]' '[:lower:]' | /usr/bin/sed '/s/^_//'`" in
bash | -bash | */bash )
[..])
	Igor
-- 
				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!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

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