From d67ec9d4b36ff59b405529a32ef793f24b402e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Sun, 7 Aug 2005 15:46:51 +0000 Subject: handle symlinks to multiarch binaries and cases where command name contains spaces --- multiarch-dispatch | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1