mirror of https://github.com/sbt/sbt.git
commit
08a489450b
|
|
@ -17,6 +17,33 @@ declare -r default_java_opts="-Dfile.encoding=UTF-8"
|
|||
### Helper methods for BASH scripts ###
|
||||
### ------------------------------- ###
|
||||
|
||||
# Bash reimplementation of realpath to return the absolute path
|
||||
realpathish () {
|
||||
(
|
||||
TARGET_FILE="$1"
|
||||
FIX_CYGPATH="$2"
|
||||
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
|
||||
COUNT=0
|
||||
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
|
||||
do
|
||||
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
COUNT=$(($COUNT + 1))
|
||||
done
|
||||
|
||||
# make sure we grab the actual windows path, instead of cygwin's path.
|
||||
if [[ "x$FIX_CYGPATH" != "x" ]]; then
|
||||
echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")"
|
||||
else
|
||||
echo "$(pwd -P)/$TARGET_FILE"
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
# Uses uname to detect if we're in the odd cygwin environment.
|
||||
is_cygwin() {
|
||||
local os=$(uname -s)
|
||||
|
|
@ -43,18 +70,7 @@ cygwinpath() {
|
|||
}
|
||||
|
||||
|
||||
declare SCRIPT=$0
|
||||
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
|
||||
declare -r sbt_bin_dir="$(dirname "$SCRIPT")"
|
||||
declare -r sbt_bin_dir="$(dirname "$(realpathish "$0")")"
|
||||
declare -r sbt_home="$(dirname "$sbt_bin_dir")"
|
||||
|
||||
echoerr () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue