This is the mail archive of the 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]

[[ ]] test always reports a "not found" error in bash shell script

Thu 2003/JUN/26 0921 PDT


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" ]]
    # Do Cygwin stuff
    # Do Linux stuff

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" ]
    # Do Cygwin stuff
    # Do Linux stuff

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
  Linux bash version  : GNU bash, version 2.05b.0(1)-release

The version of Linux we are using is Red Hat 8.0 Linux.


Attachment: cygcheck_2003-06-26_0859.out
Description: Binary data

Unsubscribe info:
Problem reports:

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