# HG changeset patch # User Meredith Howard # Date 1627454890 18000 # Node ID f87943eb16aa18c8b7038f3b465cd28319d4b664 # Parent 55c477df9d1b19c87360b5368a026a64067fdc2e stubexec fixes diff --git a/.lib/sh/stubexec.sh b/.lib/sh/stubexec.sh --- a/.lib/sh/stubexec.sh +++ b/.lib/sh/stubexec.sh @@ -1,5 +1,12 @@ +realpath() { + local dir="$(dirname -- "$1")" + local file="$(basename -- "$1")" + (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file") +} + stubexec() { - local real_bin="$(which -a $(basename $0) | grep -v $0 | head -n 1)" + local real_me="$(realpath "$0")" + local real_bin="$(which -a $(basename $0) | grep -v "$real_me" | head -n 1)" if [ -x "$real_bin" ]; then exec $real_bin $* fi diff --git a/bin/cpm b/bin/cpm --- a/bin/cpm +++ b/bin/cpm @@ -2,11 +2,11 @@ set -eu . ~/.lib/sh/stubexec.sh -stubexec $* +stubexec "$@" curl -fsSL --compressed https://git.io/cpm | perl - install -g App::cpm plenv rehash || : -stubexec $* +stubexec "$@" diff --git a/bin/pg_format b/bin/pg_format --- a/bin/pg_format +++ b/bin/pg_format @@ -2,9 +2,9 @@ set -eu . ~/.lib/sh/stubexec.sh -stubexec $* +stubexec "$@" cpanm -n 'https://github.com/darold/pgFormatter.git' plenv rehash || : -stubexec $* +stubexec "$@"