From 8c03b886c4d4b9bcfb1cb30b3704b8af561c2f45 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 1 Oct 2023 06:33:43 +0100 Subject: 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 --- script/handle/make/file | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'script/handle/make/file') diff --git a/script/handle/make/file b/script/handle/make/file index b76eadcd..600b9f3d 100755 --- a/script/handle/make/file +++ b/script/handle/make/file @@ -29,14 +29,13 @@ main() handle_dependencies() { - [ -d "${project}" ] || ./update project repo "${project%/*}" || \ - err "handle_dependencies: can't fetch ${project%/*}" + [ -d "${project}" ] || x_ ./update project repo "${project%/*}" [ -d "${project}" ] || \ err "handle_dependencies: ${project%/*} not downloaded" [ "${project}" = "uefitool" ] || return 0 # TODO: remove hardcoding ( - cd uefitool || err "handle_dependencies: !cd uefitool" + x_ cd uefitool cmake UEFIExtract/ || [ -f Makefile ] || \ err "handle_dependencies: !cmake UEFIExtract/" ) @@ -45,11 +44,9 @@ handle_dependencies() run_make_command() { if [ -z "${mode}" ]; then - make -C "${project}" -j$(nproc) || \ - err "run_make_command: !make -C ${project}" + x_ make -C "${project}" -j$(nproc) else - make -C "${project}" clean || \ - err "run_make_command: ${project}: make-clean failed" + x_ make -C "${project}" clean make -C "${project}" distclean || : fi } -- cgit v1.2.1