delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/26/12:31:40

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
Message-ID: <004301c33c00$946b6a80$12760251@ximenes>
From: "Cliff Hones" <cliff AT aonix DOT co DOT uk>
To: <cygwin AT cygwin DOT com>
Subject: Re: [[ ]] test always reports a "not found" error in bash shell script
Date: Thu, 26 Jun 2003 17:32:47 +0100
Organization: Aonix Europe Ltd.
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165

MATTHEWS,MICHAEL (HP-Vancouver,ex1) <mmatthews AT hp DOT com> wrote:
> I am porting a Linux build system to Windows XP by using the Cygwin
1.3.22-1
> environment (see the attached text file for output from "cygcheck -s -v
> -r"). All of the bash shell scripts use the [[ ]] test in if statements,
> similar to:
>
>   if [[ "$(uname -s)" != "Linux" ]]
>   then
>     # Do Cygwin stuff
>   else
>     # Do Linux stuff
>   fi
>
> Whenever I run the script in the Cygwin bash shell, the conditional
> executes, but the following error is displayed in the terminal window:
>
>   [[: not found
>
> If I replace the double square brackets with single square brackets:
>
>   if [ "$(uname -s)" != "Linux" ]
>   then
>     # Do Cygwin stuff
>   else
>     # Do Linux stuff
>   fi
>
> I do not get any error message.
>
> I use the [[ ]] test because from what I read about the bash shell
> conditional testing, using [[ ]] is better than [ ], since [[ ]] is tested
> internally, whereas [ ] is tested in a separate shell with the "test"
> command. I would prefer to not have to change all of the test conditionals
> in our Linux bash shell scripts from [[ ]] to [ ].
>
> I checked the versions of bash in Cygwin and in Linux and they are:
>
>   Cygwin bash version : GNU bash, version 2.05b.0(9)-release
> (i686-pc-cygwin)
>   Linux bash version  : GNU bash, version 2.05b.0(1)-release
> (i686-pc-linux-gnu)

By default the shell for command scripts (/bin/sh) is ash not bash on
Cygwin.
You may be inadvertently using ash.  To use bash start your
scripts with #!/bin/bash.

-- Cliff


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