# HG changeset patch # User Andreas Woess # Date 1415969352 -3600 # Node ID 194041c3fdabe9465cbc4275b3a4b6424816ca07 # Parent 4a1b4400bb1fe61e141a5d700b3866e7499cffa5 improve path resolving in mx.sh so that it can be run from outside the repo root diff -r 4a1b4400bb1f -r 194041c3fdab mxtool/mx --- a/mxtool/mx Tue Nov 18 11:03:39 2014 +0100 +++ b/mxtool/mx Fri Nov 14 13:49:12 2014 +0100 @@ -28,9 +28,13 @@ dir=`/bin/pwd` # Resolve location of this script so that mx.py can be found in the same directory -source="${BASH_SOURCE[0]}" -while [ -h "$source" ] ; do source="$(readlink "$source")"; done -dir="$( cd -P "$( dirname "$source" )" && pwd )" +source="${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}" +while [ -h "$source" ]; do + dir="$(cd -P "$(dirname "$source")" && pwd)" + source="$(readlink "$source")" + [[ $source != /* ]] && source="$dir/$source" +done +dir="$(cd -P "$(dirname "$source")" && pwd)" if [ ! -f "$dir/mx.py" ]; then echo "Cannot find mx.py in $dir"