summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGwenolé Beauchesne <gbeauchesne@mandriva.org>2005-08-07 15:46:51 +0000
committerGwenolé Beauchesne <gbeauchesne@mandriva.org>2005-08-07 15:46:51 +0000
commitd67ec9d4b36ff59b405529a32ef793f24b402e4b (patch)
treef7c8a08a41476d7b97b8591fc8f114f8fa5d48ae
parent65ad81725ca65a59be373d4bd3de5fb99ea5aebf (diff)
downloadmultiarch-utils-d67ec9d4b36ff59b405529a32ef793f24b402e4b.tar
multiarch-utils-d67ec9d4b36ff59b405529a32ef793f24b402e4b.tar.gz
multiarch-utils-d67ec9d4b36ff59b405529a32ef793f24b402e4b.tar.bz2
multiarch-utils-d67ec9d4b36ff59b405529a32ef793f24b402e4b.tar.xz
multiarch-utils-d67ec9d4b36ff59b405529a32ef793f24b402e4b.zip
handle symlinks to multiarch binaries and cases where command name contains
spaces
-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