diff options
author | Leah Rowe <leah@libreboot.org> | 2023-10-01 06:33:43 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-10-01 22:47:02 +0100 |
commit | 8c03b886c4d4b9bcfb1cb30b3704b8af561c2f45 (patch) | |
tree | 828eb1ad589300517e9a41581eee4b5d9605d3e8 /script/build/grub/payload | |
parent | 5f914a4d00da5ab9324c55eaecc40aa2ee000f63 (diff) |
Greatly simplify error handling in shell scripts
Instead of having detailed error messages, run most
commands through a function that calls err() under
fault conditions.
Where detail is still required, err() is still called
manually. Where it isn't, the error message is simply
whatever command was executed to cause the error.
This results in a massive sloccount reduction for lbmk;
specifically, 178 sloc reduction, or a 8.1% reduction.
The total sloccount is now 2022, for shell scripts.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/grub/payload')
-rwxr-xr-x | script/build/grub/payload | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/script/build/grub/payload b/script/build/grub/payload index 6f4c421a..a1bb3554 100755 --- a/script/build/grub/payload +++ b/script/build/grub/payload @@ -22,16 +22,12 @@ main() handle_dependencies() { [ -d "grub/" ] || \ - ./update project repo grub || \ - err "handle_dependencies: cannot fetch grub" + x_ ./update project repo grub [ -f "grub/grub-mkstandalone" ] || \ - ./build grub utils || \ - err "handle_dependencies: cannot build grub utils" + x_ ./build grub utils [ -d "${elfdir}" ] || \ - mkdir -p "${elfdir}" || \ - err "handle_dependencies: cannot mkdir ${elfdir}" - rm -f "${elfdir}/"* || \ - err "handle_dependencies: cannot rm inside: ${elfdir}/" + x_ mkdir -p "${elfdir}" + x_ rm -f "${elfdir}/"* } build_keymap_configs() @@ -40,9 +36,8 @@ build_keymap_configs() [ -f "${keylayoutfile}" ] || continue keymap="${keylayoutfile##${grubcfgsdir}/keymap/}" keymap="${keymap%.gkb}" - printf "keymap %s\n" "${keymap}" > \ - "${elfdir}/keymap_${keymap}.cfg" || \ - err "mk_keymap: can't make ${elfdir}/keymap_${keymap}.cfg" + x_ printf "keymap %s\n" "${keymap}" > \ + "${elfdir}/keymap_${keymap}.cfg" done } |