diff options
author | Leah Rowe <leah@libreboot.org> | 2025-09-26 00:09:46 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-09-26 00:09:46 +0100 |
commit | e42cb4f4cd513f512397ff7a46b6174b39a9708e (patch) | |
tree | ab6ba25c737cfa17ed6bc6eb9e1c4f5419ff892b /include/lib.sh | |
parent | f5060232e16ab1c041f0108a5f65d8f96f79756d (diff) |
xbmk: tidy up some if statements
this is an extension of the previous work to unroll
most of the condensed code lines.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/lib.sh')
-rw-r--r-- | include/lib.sh | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/include/lib.sh b/include/lib.sh index 499fb329..2ff410eb 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -89,24 +89,25 @@ e() setvars() { _setvars="" + if [ $# -lt 2 ]; then printf "err \"setvars: too few args\\n\"" return 0 - fi - val="$1" - shift 1 - while [ $# -gt 0 ]; do - printf "%s=\"%s\"\n" "$1" "$val" + else + val="$1" shift 1 - done + while [ $# -gt 0 ]; do + printf "%s=\"%s\"\n" "$1" "$val" + shift 1 + done + fi } setcfg() { if [ $# -gt 1 ]; then printf "e \"%s\" f missing && return %s;\n" "$1" "$2" - fi - if [ $# -lt 2 ]; then + else printf "e \"%s\" f not && err \"Missing config '$1'\";\n" "$1" fi printf ". \"%s\" || err \"Could not read config '$1'\";\n" "$1" @@ -205,19 +206,18 @@ x_() { if [ $# -lt 1 ]; then return 0 - fi - if [ -z "$1" ]; then + elif [ -z "$1" ]; then err "Empty first arg" "x_" "$@" + else + "$@" || err "Unhandled error" "x_" "$@" fi - "$@" || err "Unhandled error" "x_" "$@" } xchk() { if [ $# -lt 3 ]; then err "$1 needs at least two arguments" "xchk" "$@" - fi - if [ -z "$2" ] || [ -z "$3" ]; then + elif [ -z "$2" ] || [ -z "$3" ]; then err "arguments must not be empty" "xchk" "$@" fi } |