Permalink
Browse files

More robust findScalaHome in bash scripts. See SI-5792

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 ed6daea665eccad2ab5394c0a5c36069aaf9a81f
Showing with 8 additions and 13 deletions.
  1. +8 −13 src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -9,19 +9,14 @@
##############################################################################
findScalaHome () {
- # see SI-2092
- local SOURCE="${BASH_SOURCE[0]}"
- while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
- local bindir="$( dirname "$SOURCE" )"
- if [[ -d "$bindir"/.. ]]; then
- ( cd -P "$bindir"/.. && pwd )
- else
- # See SI-5792
- local dir=$(dirname "${BASH_SOURCE[0]}")
- local link=$(dirname "$(readlink "${BASH_SOURCE[0]}")")
- local path="$dir/$link/.."
- ( cd "$path" && pwd )
- fi
+ # see SI-2092 and SI-5792
+ local source="${BASH_SOURCE[0]}"
+ while [ -h "$source" ] ; do
+ local linked="$(readlink "$source")"
+ local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )"
+ source="$dir/$(basename "$linked")"
+ done
+ ( cd -P "$(dirname "$source")/.." && pwd )
}
execCommand () {
[[ -n $SCALA_RUNNER_DEBUG ]] && echo "" && for arg in "$@@"; do echo "$arg"; done && echo "";

0 comments on commit ed6daea

Please sign in to comment.