summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-09-14 11:54:52 +0100
committerLeah Rowe <leah@libreboot.org>2026-09-14 11:54:52 +0100
commitc4695497f5b0b74e07d68d69875274a38e0a62c4 (patch)
tree740b94aaf2a2fcc6b7f84721e59f674b42d28b93
parentd9ca4265ef58d58d1068b67cec445f7baec80528 (diff)
mk: simplified error functions
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xmk22
1 files changed, 6 insertions, 16 deletions
diff --git a/mk b/mk
index bddf319e..890a3465 100755
--- a/mk
+++ b/mk
@@ -35,26 +35,16 @@ findpath()
x_()
{
- [ $# -lt 1 ] && \
- return 0
- [ -z "$1" ] && \
- err "Empty first arg" "x_" "$@"
-
- "$@" || err "Unhandled error" "x_" "$@"
+ [ $# -lt 1 ] || "$@" || \
+ err "Unhandled error" "x_" "$@"; :
}
err()
{
- if [ $# -eq 1 ]; then
- printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || :
- elif [ $# -gt 1 ]; then
- printf "ERROR %s: %s: in command with args: " "$0" "$1" 1>&2
- shift 1
- printf '%s\n' "$@" | awk '{printf "\"%s\" ", $0}'
- printf "\n"
- else
- printf "ERROR, but no arguments provided to err\n" 1>&2
- fi
+ printf "ERROR %s: %s: " "${0-}" "${1-}" 1>&2
+ shift 1 2>/dev/null || :
+ printf '%s\n' "$@" | awk '{printf "\"%s\" ", $0}'
+ printf "\n"
exit 1
}