#!/bin/sh
##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements.  See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership.  The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License.  You may obtain a copy of the License at
##
##  http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied.  See the License for the
## specific language governing permissions and limitations
## under the License.
##

##
## $Rev: 539227 $ $Date: 2007-05-17 19:48:49 -0700 (Thu, 17 May 2007) $
##

DIRNAME=`dirname "$0"`

# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
    CYGWIN*)
        cygwin=true
        ;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
    [ -n "$GSHELL_HOME" ] && GSHELL_HOME=`cygpath --unix "$GSHELL_HOME"`
    [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Locate GSHELL_HOME if not it is not set
if [ "x$GSHELL_HOME" = "x" ]; then
    GSHELL_HOME=`cd "$DIRNAME/.."; pwd`
fi

# Determine the Java command to use to start the JVM
if [ -z "$JAVACMD" ]; then
    if [ -n "$JAVA_HOME" ]; then
        JAVACMD="$JAVA_HOME/bin/java"
    else
        JAVACMD="java"
    fi
fi

BOOTJAR="$GSHELL_HOME/lib/boot/gshell-bootstrap.jar"
if $cygwin ; then
    BOOTJAR=`cygpath --windows "$BOOTJAR"`
fi

# Start the JVM
exec "$JAVACMD" $JAVA_OPTS -jar "$BOOTJAR" "$@"

