summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-09-14 12:47:01 +0100
committerLeah Rowe <leah@libreboot.org>2026-09-14 12:47:01 +0100
commite99be6e5dcadeb723434203f0dc1cf2bfa63962f (patch)
tree1fe910df9a80637e5298df5f457bcd8a8ac53eb4
parente075a798672807be3e8f97991eeb18680673b98f (diff)
mk: ruthlessly simplify findpath()
i love eval, printf and awk eval, printf and awk are the best things ever Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xmk12
1 files 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_()