Skip to content

Instantly share code, notes, and snippets.

@sgalles
Created June 5, 2014 20:18
Show Gist options
  • Save sgalles/6070bcfdebb29874853e to your computer and use it in GitHub Desktop.
Save sgalles/6070bcfdebb29874853e to your computer and use it in GitHub Desktop.
Ceylon start script with cygwin support
#!/bin/sh
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done
# detect cygwin
CYGWIN=false
case "`uname`" in
CYGWIN* )
CYGWIN=true
;;
esac
DIR=$(dirname "$PRG")
CEYLON_HOME="$DIR/.."
if test -z "$JAVA_HOME"
then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi
# Make sure we have java installed
if hash java 2>&-
then
true #nothing
else
echo "Java not found, you must install Java in order to compiler and run Ceylon programs"
echo "Go to http://www.java.com/getjava/ to download the latest version of Java"
fi
LIB="$CEYLON_HOME/lib"
#JAVA_DEBUG_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
if [ "$PRESERVE_JAVA_OPTS" != "true" ]; then
PREPEND_JAVA_OPTS="$JAVA_DEBUG_OPTS"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.terminal.width=$(tput 2>/dev/null cols)"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.terminal.color.white=$(tput 2>/dev/null setaf 7)"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.terminal.color.green=$(tput 2>/dev/null setaf 2)"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.terminal.color.red=$(tput 2>/dev/null setaf 1)"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.progname=$(basename $PRG)"
fi
JAVA_OPTS="$PREPEND_JAVA_OPTS $JAVA_OPTS"
BOOTSTRAP_JAR="$LIB/ceylon-bootstrap.jar"
if $CYGWIN; then
BOOTSTRAP_JAR=`cygpath --windows "$BOOTSTRAP_JAR"`
fi
exec "$JAVA" \
$JAVA_OPTS \
-jar "$BOOTSTRAP_JAR" \
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment