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]

Re: Possible bash incompatibility


On Mon, Apr 18, 2005 at 10:59:10AM -0400, Igor Pechtchanski wrote:
>On Mon, 18 Apr 2005, Arash Partow wrote:
>>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 ...

How about

if [[ $(uname -s) == CYGWIN* ]]; then

cgf

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


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