views:

532

answers:

2

I'm trying to use Cygwin to test startup scripts for a Java application that is going to run in a Linux environment.

The troule is when I specify a boothclasspath or Classpath I need to use OS specific path seperators ";" for windows, and ":" for Linux. This happens because Java is still a native windows application and uses the native OS path seperator (Cygwin List Path Seperator )

Is there any way in the shell script to detect what OS I'm on (or perhaps if I'm running in CYGWIN), and specify the proper path seperator.

I'm trying to set the following:

MAVEN_OPTS="-Xbootclasspath/a:test/resources:live/resources"

On Windows it would need to be: MAVEN_OPTS="-Xbootclasspath/a:test/resources;live/resources"

+1  A: 

Found an answer here: Detect OS from a bash script (Using $OSTYPE)

PATHSEP=":" 
if [[ $OSTYPE == "cygwin" ]] ; then
PATHSEP=";" 
fi

MAVEN_OPTS="-Xbootclasspath/a:test/resources${PATHSEP}live/resources"
Dougnukem
A: 

You can use uname(1) to test if you're running Cygwin, e.g.:

if uname | grep -iq cygwin; then
    # use ; for path separator
else
    # use : for path separator
fi
Adam Rosenfield