]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
Instead of "cd .." hackery, find the path of ./all by looking at $0.
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 24 Oct 2016 17:53:51 +0000 (13:53 -0400)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 24 Oct 2016 17:53:51 +0000 (13:53 -0400)
This only supports invoking ./all directly (not via $PATH or symlinks),
but should already be a lot better than before.

all

diff --git a/all b/all
index 7d54d00cae2823eda957da69789660020f2d8dd8..a6e8ebb0372a24e3d3814c071eee6557507bf7d5 100755 (executable)
--- a/all
+++ b/all
@@ -19,15 +19,20 @@ LF="
 ESC="\e"
 
 d00=`pwd`
-while ! [ -f ./all ]; do
-       if [ x"`pwd`" = x"/" ]; then
+case "$0" in
+       /*/all)
+               export d0=${0%/all}
+               ;;
+       */all)
+               export d0=$d00/${0%/all}
+               ;;
+       *)
                $ECHO "Cannot find myself."
                $ECHO "Please run this script with the working directory inside a Xonotic checkout."
-               exit 1
-       fi
-       cd ..
-done
-export d0=`pwd`
+               ;;
+esac
+cd "$d0"
+d0=`pwd`
 SELF="$d0/all"
 
 # If we are on WINDOWS: