]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Minor, correct arc handling of relative symlinking (from @makinde).
authorepriestley <git@epriestley.com>
Fri, 30 Mar 2012 21:56:19 +0000 (14:56 -0700)
committerepriestley <git@epriestley.com>
Mon, 2 Apr 2012 23:33:36 +0000 (16:33 -0700)
bin/arc

diff --git a/bin/arc b/bin/arc
index 4436fa89fb1e0a4f82d68753d916a441cda7db32..d90715e7dc086fe8843588bc7f5ba317fee6628d 100755 (executable)
--- a/bin/arc
+++ b/bin/arc
@@ -7,9 +7,15 @@
 # symlinks, etc.
 SOURCE="${BASH_SOURCE[0]}";
 while [ -h "$SOURCE" ]; do
-  SOURCE="$(readlink "$SOURCE")";
+  LINK="$(readlink "$SOURCE")";
+  if [ "${LINK:0:1}" == "/" ]; then
+    # absolute symlink
+    SOURCE="$LINK"
+  else
+    # relative symlink
+    SOURCE="$(cd -P "$(dirname "$SOURCE")" && pwd)/$LINK"
+  fi
 done;
 DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
 
 exec $DIR/../scripts/arcanist.php "$@"
-