diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-09-14 11:54:52 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-09-14 11:54:52 +0100 |
| commit | c4695497f5b0b74e07d68d69875274a38e0a62c4 (patch) | |
| tree | 740b94aaf2a2fcc6b7f84721e59f674b42d28b93 | |
| parent | d9ca4265ef58d58d1068b67cec445f7baec80528 (diff) | |
mk: simplified error functions
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rwxr-xr-x | mk | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -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 } |
