Add age limit reinstall check

Fri, 09 Sep 2022 12:30:42 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Fri, 09 Sep 2022 12:30:42 -0400
changeset 1002
8284b9cac608
parent 1001
0597cb8f2d07
child 1003
0cf4b33dd117

Add age limit reinstall check

.lib/sh/stubexec.sh file | annotate | diff | comparison | revisions
bin/gum file | annotate | diff | comparison | revisions
--- a/.lib/sh/stubexec.sh
+++ b/.lib/sh/stubexec.sh
@@ -19,6 +19,12 @@ shim_filter() {
   done
 }
 
+age_check() {
+  local subject=''
+  read subject
+  find "$subject" -mtime -${age_limit:-90} -print
+}
+
 realbin() {
   local bn="$(basename $1)"
   which -a "$bn" |
@@ -28,11 +34,12 @@ realbin() {
 }
 
 stubexec() {
-  local real_bin="$(realbin "$0")"
+  local real_bin="$(realbin "$0" | age_check)"
   if [ -x "$real_bin" ]; then
     exec "$real_bin" "$@"
   fi
   install_it
+  touch "$(realbin "$0")"  # In case of no updates
   stubexec "$@"
 }
 
--- a/bin/gum
+++ b/bin/gum
@@ -1,7 +1,7 @@
 #!/bin/sh
 set -eu
 
-# TODO: add an expiry system to stubexec?
+age_limit=7
 
 install_it() {
   go install github.com/charmbracelet/gum@latest

mercurial