aboutsummaryrefslogblamecommitdiff
path: root/bin/dotr
blob: 90d2825e6b5c5d4425ea5fde3504f00f393fe62f (plain) (tree)
1
2
3
4
5
6
7
8
9


                                               
                                                                               


                                  
                                     
                                                                     
 

                                     


                                                                                            

                  










                                                                                                           


                    

                                     


                
#!/bin/bash

# Try to autodetect real location of the script
DOTTY_ROOT="$(readlink "$0")"              #  relative, symbolic links resolved
if [[ "$DOTTY_ROOT" == "" ]]; then
  DOTTY_ROOT="$0"
fi
DOTTY_ROOT="$(dirname "$DOTTY_ROOT")"
DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.."  # absolute

# Load common functions and variables
source $DOTTY_ROOT/bin/common

# CLASS_PATH is derived from the DOTTY_ROOT and SCALA_LIBRARY_JAR
CLASS_PATH="-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-2.11/classes/:.:$SCALA_LIBRARY_JAR"

function runMain {
    local jbin=$(which "java")

    if [ ! -z "$JAVA_BIN" ]; then
        jbin=$JAVA_BIN
    fi

    if [ "$jbin" == "" ]; then
        echo "java bin not detected - please specify with \$JAVA_BIN or install java to a default location"
    else
        eval "$jbin $CLASS_PATH $@"
    fi
}

if [ -z "$1" ]; then
    echo "Starting dotty REPL..."
    eval "$DOTTY_ROOT/bin/dotc -repl"
else
    runMain "$@"
fi