Skip to content

Commit

Permalink
More robust findScalaHome in bash scripts. See SI-5792
Browse files Browse the repository at this point in the history
Allows multiple absolute or relative symlinks by jumping through
the directories while following the links.
  • Loading branch information
pvlugter committed Jun 1, 2012
1 parent 71006c0 commit ed6daea
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/compiler/scala/tools/ant/templates/tool-unix.tmpl
Expand Up @@ -9,19 +9,14 @@
############################################################################## ##############################################################################


findScalaHome () { findScalaHome () {
# see SI-2092 # see SI-2092 and SI-5792
local SOURCE="${BASH_SOURCE[0]}" local source="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done while [ -h "$source" ] ; do
local bindir="$( dirname "$SOURCE" )" local linked="$(readlink "$source")"
if [[ -d "$bindir"/.. ]]; then local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )"
( cd -P "$bindir"/.. && pwd ) source="$dir/$(basename "$linked")"
else done
# See SI-5792 ( cd -P "$(dirname "$source")/.." && pwd )
local dir=$(dirname "${BASH_SOURCE[0]}")
local link=$(dirname "$(readlink "${BASH_SOURCE[0]}")")
local path="$dir/$link/.."
( cd "$path" && pwd )
fi
} }
execCommand () { execCommand () {
[[ -n $SCALA_RUNNER_DEBUG ]] && echo "" && for arg in "$@@"; do echo "$arg"; done && echo ""; [[ -n $SCALA_RUNNER_DEBUG ]] && echo "" && for arg in "$@@"; do echo "$arg"; done && echo "";
Expand Down

0 comments on commit ed6daea

Please sign in to comment.