spin out stubexec

Sat, 19 Jun 2021 21:43:19 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 19 Jun 2021 21:43:19 -0500
changeset 915
55a1c83b3417
parent 914
54729706345b
child 916
fed7d34cdfff

spin out stubexec

.lib/sh/stubexec.sh file | annotate | diff | comparison | revisions
bin/cpm file | annotate | diff | comparison | revisions
bin/pg_format file | annotate | diff | comparison | revisions
new file mode 100644
--- /dev/null
+++ b/.lib/sh/stubexec.sh
@@ -0,0 +1,6 @@
+stubexec() {
+  local real_bin="$(which -a $(basename $0) | grep -v $0 | head -n 1)"
+  if [ -x "$real_bin" ]; then
+    exec $real_bin $*
+  fi
+}
new file mode 100755
--- /dev/null
+++ b/bin/cpm
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -eu
+. ~/.lib/sh/stubexec.sh
+
+stubexec $*
+
+curl -fsSL --compressed https://git.io/cpm |
+  perl - install -g App::cpm
+
+plenv rehash || :
+
+stubexec $*
--- a/bin/pg_format
+++ b/bin/pg_format
@@ -1,16 +1,10 @@
 #!/bin/sh
 set -eu
-
-stubexec() {
-  local real_bin="$(which -a $(basename $0) | grep -v $0 | head -n 1)"
-  if [ -x "$real_bin" ]; then
-    exec $real_bin $*
-  fi
-}
+. ~/.lib/sh/stubexec.sh
 
 stubexec $*
 
 cpanm -n 'https://github.com/darold/pgFormatter.git'
-plenv rehash
+plenv rehash || :
 
 stubexec $*

mercurial