.lib/sh/stubexec.sh

Sun, 15 Aug 2021 23:52:22 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 15 Aug 2021 23:52:22 -0400
changeset 934
fb0cbf65b726
parent 932
f87943eb16aa
child 957
ea852d545173
permissions
-rw-r--r--

add kshenoy/vim-signature

932
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
1 realpath() {
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
2 local dir="$(dirname -- "$1")"
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
3 local file="$(basename -- "$1")"
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
4 (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
5 }
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
6
915
55a1c83b3417 spin out stubexec
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 stubexec() {
932
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
8 local real_me="$(realpath "$0")"
f87943eb16aa stubexec fixes
Meredith Howard <mhoward@roomag.org>
parents: 915
diff changeset
9 local real_bin="$(which -a $(basename $0) | grep -v "$real_me" | head -n 1)"
915
55a1c83b3417 spin out stubexec
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 if [ -x "$real_bin" ]; then
55a1c83b3417 spin out stubexec
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 exec $real_bin $*
55a1c83b3417 spin out stubexec
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 fi
55a1c83b3417 spin out stubexec
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 }

mercurial