Thu, 25 Nov 2021 14:13:46 -0500
improve stubexec
.lib/sh/stubexec.sh | file | annotate | diff | comparison | revisions | |
bin/cpm | file | annotate | diff | comparison | revisions | |
bin/gotags | file | annotate | diff | comparison | revisions | |
bin/pg_format | file | annotate | diff | comparison | revisions |
--- a/.lib/sh/stubexec.sh +++ b/.lib/sh/stubexec.sh @@ -4,10 +4,17 @@ realpath() { (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file") } +realbin() { + which -a $(basename $1) | + grep -v "$(realpath $1)" | + head -n 1 +} + stubexec() { - local real_me="$(realpath "$0")" - local real_bin="$(which -a $(basename $0) | grep -v "$real_me" | head -n 1)" + local real_bin="$(realbin "$0")" if [ -x "$real_bin" ]; then - exec $real_bin $* + exec "$real_bin" $* fi + install_it + stubexec $* }
--- a/bin/cpm +++ b/bin/cpm @@ -2,11 +2,11 @@ set -eu . ~/.lib/sh/stubexec.sh -stubexec "$@" +install_it() { + curl -fsSL --compressed https://git.io/cpm | + perl - install -g App::cpm -curl -fsSL --compressed https://git.io/cpm | - perl - install -g App::cpm - -plenv rehash || : + plenv rehash || : +} stubexec "$@"