.lib/sh/stubexec.sh

changeset 957
ea852d545173
parent 932
f87943eb16aa
child 958
b883fb5c4792
equal deleted inserted replaced
956:61c91bec34c8 957:ea852d545173
2 local dir="$(dirname -- "$1")" 2 local dir="$(dirname -- "$1")"
3 local file="$(basename -- "$1")" 3 local file="$(basename -- "$1")"
4 (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file") 4 (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
5 } 5 }
6 6
7 realbin() {
8 which -a $(basename $1) |
9 grep -v "$(realpath $1)" |
10 head -n 1
11 }
12
7 stubexec() { 13 stubexec() {
8 local real_me="$(realpath "$0")" 14 local real_bin="$(realbin "$0")"
9 local real_bin="$(which -a $(basename $0) | grep -v "$real_me" | head -n 1)"
10 if [ -x "$real_bin" ]; then 15 if [ -x "$real_bin" ]; then
11 exec $real_bin $* 16 exec "$real_bin" $*
12 fi 17 fi
18 install_it
19 stubexec $*
13 } 20 }

mercurial