akinomurasame/redpen_ruby

View on GitHub
lib/redpen-cli-1.1/bin/redpen

Summary

Maintainability
Test Coverage
#!/bin/sh
##
## RedPen startup script
##

SCRIPT="$0"

# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
while [ -h "$SCRIPT" ] ; do
  ls=`ls -ld "$SCRIPT"`
  # Drop everything prior to ->
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    SCRIPT="$link"
  else
    SCRIPT=`dirname "$SCRIPT"`/"$link"
  fi
done

# Find RedPen home
REDPEN_HOME=`dirname "$SCRIPT"`/..

# Make REDPEN_HOME absolute
REDPEN_HOME=`cd "$REDPEN_HOME"; pwd`
REDPEN_CLASSPATH=$REDPEN_HOME/conf/*:$REDPEN_HOME/lib/*

if [ -z "$JAVA_HOME" ]; then
    echo "Error: JAVA_HOME is not defined. Can not start RedPen" 1>&2
    exit 1
fi

JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=$REDPEN_HOME/conf/logback.xml"
JAVA_CMD="$JAVA_HOME/bin/java"

if [ ! -x "$JAVA_CMD" ]; then
    echo "Error: $JAVA_CMD is not execututable. Can not start RedPen" 1>&2
    exit 1
fi

exec "$JAVA_CMD" $JAVA_OPTS \
  -classpath "$REDPEN_CLASSPATH" \
  cc.redpen.Main \
  "$@"