filter out shims that wont work

Thu, 25 Nov 2021 21:19:03 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 25 Nov 2021 21:19:03 -0500
changeset 958
b883fb5c4792
parent 957
ea852d545173
child 959
4a5aaef00594

filter out shims that wont work

.lib/sh/stubexec.sh file | annotate | diff | comparison | revisions
--- a/.lib/sh/stubexec.sh
+++ b/.lib/sh/stubexec.sh
@@ -4,9 +4,25 @@ realpath() {
   (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
 }
 
+shim_filter() {
+  local binpath=''
+  while read binpath; do
+    case "$binpath" in
+      */.plenv/shims/*)
+        plenv which $1 >/dev/null 2>&1 || continue
+        ;;
+      */.asdf/shims/*)
+        asdf which $1 >/dev/null 2>&1 || continue
+        ;;
+    esac
+    echo "$binpath"
+  done
+}
+
 realbin() {
   which -a $(basename $1) |
     grep -v "$(realpath $1)" |
+    shim_filter |
     head -n 1
 }
 

mercurial