diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-09-11 14:41:18 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-09-11 16:18:09 +0100 |
| commit | 15204cda6364afe4e50b3dfe365b4638910a3334 (patch) | |
| tree | 5d59f9bdf29186ee23b1a79f671a7f03cbea4824 /include/inject.sh | |
| parent | 8173aea83be24e807bed40bec2e2eca33d87b4e3 (diff) | |
xbmk: re-introduce condensed if statements
i've been careful to makely only use it on AND operations,
not onse that use OR. a lot of blocks are not condensed,
unlike previously when this design was used.
i removed the condensed design because it made the code
allegedly easier to read, but i found it harder to read
and found the code looked dirty. this change makes it
clean again, but i've done it in a way where the shorthand
conditional statements are easy to understand for most
people. this strikes a compromise; i would go further.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/inject.sh')
| -rw-r--r-- | include/inject.sh | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/include/inject.sh b/include/inject.sh index b915fb66..b037d2c5 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -18,9 +18,8 @@ inject() { remkdir "$tmpromdel" - if [ $# -lt 1 ]; then + [ $# -lt 1 ] && \ err "No options specified" "inject" "$@" - fi archive="$1"; new_mac="xx:xx:xx:xx:xx:xx" @@ -36,18 +35,16 @@ inject() setmac) if [ $# -gt 2 ]; then new_mac="$3" && \ - if [ -z "$new_mac" ]; then - err "Empty MAC address specified" "inject" "$@" - fi + [ -z "$new_mac" ] && \ + err "Empty MAC address" "inject" "$@"; : fi ;; *) err "Unrecognised inject mode: '$2'" "inject" "$@" ;; esac - if [ "$new_mac" = "keep" ]; then + [ "$new_mac" = "keep" ] && \ new_mac="" - fi check_release if check_target; then @@ -55,9 +52,8 @@ inject() return 0 fi fi - if [ "$xchanged" = "y" ]; then + [ "$xchanged" = "y" ] && \ remktar - fi if [ "$xchanged" = "y" ]; then printf "\n'%s' was modified\n" "$archive" 1>&2 @@ -70,9 +66,8 @@ inject() check_release() { - if [ -L "$archive" ]; then + [ -L "$archive" ] && \ err "'$archive' is a symlink" "check_release" "$@" - fi if e "$archive" f missing; then err "'$archive' missing" "check_release" "$@" fi @@ -80,9 +75,8 @@ check_release() archivename="`basename "$archive" || err "Can't get '$archive' name"`" \ || err "can't get '$archive' name" "check_release" "$@" - if [ -z "$archivename" ]; then + [ -z "$archivename" ] && \ err "Can't determine archive name" "check_release" "$@" - fi case "$archivename" in *_src.tar.xz) @@ -102,9 +96,8 @@ check_release() check_target() { - if [ "$board" != "${board#serprog_}" ]; then + [ "$board" != "${board#serprog_}" ] && \ return 1 - fi boarddir="$cbcfgsdir/$board" @@ -119,16 +112,14 @@ check_target() ifdtool="elf/coreboot/$tree/ifdtool" - if [ -n "$IFD_platform" ]; then - ifdprefix="-p $IFD_platform" - fi + [ -n "$IFD_platform" ] && \ + ifdprefix="-p $IFD_platform"; : } patch_release() { - if [ "$nuke" != "nuke" ]; then + [ "$nuke" != "nuke" ] && \ x_ ./mk download "$board" - fi has_hashes="n" tmpromdir="$tmpromdel/bin/$board" |
