Bash syntax error: "[[: not found"

Viewed 61969

I'm working with a bash script that is currently working on a server (RHEL4). I'm developing on my laptop with Ubuntu 10.04, but I don't think the platform is causing the problem.

Here's what's happening: I have a skeleton script that calls another script that does most of the work. However, it makes calls to getConfig.sh a lot. getConfig.sh basically just parses some command line argument (using getopts) and calls a Java program to parse some XML files. Anyways, getConfig.sh is throwing up lots of errors (but still seems to work).

Here's the message that I'm getting

getconfig.sh: 89: [[: not found
getconfig.sh: 89: [[: not found
getconfig.sh: 94: [[: not found

I get those three errors every time it runs; however, the script completes and the Java code runs.

Here's the relavent code section

parseOptions $*

if [[ "${debugMode}" == "true" ]] ; then
    DEBUG="-DDEBUG=true"
    echo "${JAVA_HOME}/bin/java ${DEBUG} -Djava.endorsed.dirs=${JAXP_HOME} -jar $(dirname $0)/GetXPath.jar ${XML_File} ${XPath_Query}"
fi

Line 89 is "parseOptions $* and line 94 is "fi"

Thanks for the answers.

3 Answers

Use:

bash scriptname.sh

instead of:

sh scriptname.sh

Related