Wed, 28 Jul 2021 01:48:10 -0500
stubexec fixes
.lib/sh/stubexec.sh | file | annotate | diff | comparison | revisions | |
bin/cpm | file | annotate | diff | comparison | revisions | |
bin/pg_format | file | annotate | diff | comparison | revisions |
--- 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