delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/18/10:59:32

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: Mon, 18 Apr 2005 10:59:10 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Arash Partow <arashp AT hotmail DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Possible bash incompatibility
In-Reply-To: <BAY20-F859F5D44AF9EA3A9E691DD6290@phx.gbl>
Message-ID: <Pine.GSO.4.61.0504181047370.19797@slinky.cs.nyu.edu>
References: <BAY20-F859F5D44AF9EA3A9E691DD6290 AT phx DOT gbl>
MIME-Version: 1.0

On Mon, 18 Apr 2005, Arash Partow wrote:

> Hi all,
>
> Could someone tell me why the piece of bash script below is being
> rejected as being erroneous on cygwin but works fine on other bash's
> ie: linux and openbsd?

I would imagine because the output of "uname -s" doesn't contain "CYGWIN"
on either Linux or OpenBSD, so "grep -c" outputs a 0.  But even on Cygwin
this works (as Brian already confirmed).

> my current version of bash is update (2.05b).
>
> #!/bin/bash
>
> if [ `uname -s | grep -c 'CYGWIN'` -eq "1" ]; then

FWIW, a better test would be

if uname -s | grep -q 'CYGWIN'; then ...

> printf "Target platform is Win32 via CYGWIN\n";
> else
> printf "Target platform is NOT Win32 via CYGWIN\n";
> fi
>
> error message:
> bash-2.05b$ ./test.sh
> ./test.sh: line 3: [: too many arguments
> Target platform is NOT Win32 via CYGWIN
> bash-2.05b$

You could try "set -x" to see the actual command that is executed...  It
could be due to some stderr output from either uname or grep.
In any case, other than the output of "uname" containing CYGWIN (i.e.,
changes in data), none of the above is Cygwin-specific.
	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