Mon, 15 Aug 2022 12:03:06 -0500
fix for old vim version sticking around
932 | 1 | realpath() { |
2 | local dir="$(dirname -- "$1")" | |
3 | local file="$(basename -- "$1")" | |
4 | (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file") | |
5 | } | |
6 | ||
958
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
7 | shim_filter() { |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
8 | local binpath='' |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
9 | while read binpath; do |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
10 | case "$binpath" in |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
11 | */.plenv/shims/*) |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
12 | plenv which $1 >/dev/null 2>&1 || continue |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
13 | ;; |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
14 | */.asdf/shims/*) |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
15 | asdf which $1 >/dev/null 2>&1 || continue |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
16 | ;; |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
17 | esac |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
18 | echo "$binpath" |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
19 | done |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
20 | } |
b883fb5c4792
filter out shims that wont work
Meredith Howard <mhoward@roomag.org>
parents:
957
diff
changeset
|
21 | |
957 | 22 | realbin() { |
960 | 23 | local bn="$(basename $1)" |
24 | which -a "$bn" | | |
957 | 25 | grep -v "$(realpath $1)" | |
960 | 26 | shim_filter "$bn" | |
957 | 27 | head -n 1 |
28 | } | |
29 | ||
915 | 30 | stubexec() { |
957 | 31 | local real_bin="$(realbin "$0")" |
915 | 32 | if [ -x "$real_bin" ]; then |
995 | 33 | exec "$real_bin" "$@" |
915 | 34 | fi |
957 | 35 | install_it |
995 | 36 | stubexec "$@" |
915 | 37 | } |
992
4e3e37ce84bc
Switch stubexec to self-invoke
Meredith Howard <mhoward@roomag.org>
parents:
960
diff
changeset
|
38 | |
4e3e37ce84bc
Switch stubexec to self-invoke
Meredith Howard <mhoward@roomag.org>
parents:
960
diff
changeset
|
39 | stubexec "$@" |