From e99be6e5dcadeb723434203f0dc1cf2bfa63962f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 14 Sep 2026 12:47:01 +0100 Subject: [PATCH] mk: ruthlessly simplify findpath() i love eval, printf and awk eval, printf and awk are the best things ever Signed-off-by: Leah Rowe --- mk | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mk b/mk index 9ce58fe2..55b35a14 100755 --- a/mk +++ b/mk @@ -16,16 +16,8 @@ eval "`printf "LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE \ findpath() { - [ $# -gt 0 ] && while [ $# -gt 0 ]; do - found="`readlink -f "$1" 2>/dev/null`" || return 1; : - [ -n "$found" ] || \ - found="`realpath "$1" 2>/dev/null`" || return 1 - - printf "%s\n" "$found" - shift 1 - done && return 0 - - err "findpath: No arguments provided" "findpath" "$@" + eval "$(printf '%s\n' "$@" | awk '{printf \ + "readlink -f \"%s\" || realpath \"%s\" || return 1;\n", $0, $0}')" } x_()