summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmultiarch-dispatch14
1 files changed, 13 insertions, 1 deletions
diff --git a/multiarch-dispatch b/multiarch-dispatch
index 886bac2..61ce0bd 100755
--- a/multiarch-dispatch
+++ b/multiarch-dispatch
@@ -13,7 +13,19 @@ if [[ "$0" = "/usr/bin/multiarch-dispatch" ]]; then
exit 0
fi
-bin=`dirname $0`/`multiarch-platform`/${0##*/}
+# go through symlinks until multiarch-dispatch leaf is reached
+mprog="$0"
+mcomp="$mprog"
+while [[ -L "$mcomp" ]]; do
+ mprog="$mcomp"
+ mcomp=`readlink "$mprog"`
+ case "$mcomp" in
+ /*) ;;
+ *) mcomp=`dirname "$mprog"`/"$mcomp";;
+ esac
+done
+
+bin=`dirname "$mprog"`/`multiarch-platform`/"${mprog##*/}"
if [[ ! -x "$bin" ]]; then
echo "Cannot execute $bin" > /dev/stderr