From 655d3cdc881f72d2fdd0797ad92edae2f36ac73e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 23 Dec 2023 16:16:26 +0000 Subject: lbmk scripts: general code cleanup/optimisation Signed-off-by: Leah Rowe --- build | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'build') diff --git a/build b/build index e06c1cea..ac6db677 100755 --- a/build +++ b/build @@ -37,22 +37,16 @@ main() { xx_ id -u 1>/dev/null 2>/dev/null [ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help" - if [ "${1}" = "dependencies" ]; then - xx_ install_packages $@ - lbmk_exit 0 - fi - - initialise_command $@ && shift 1 - check_git - check_project - git_init + [ "${1}" = "dependencies" ] && xx_ install_packages $@ && lbmk_exit 0 - execute_command $@ + for cmd in initcmd check_git check_project git_init excmd; do + eval "${cmd} \$@" + done lbmk_exit 0 } -initialise_command() +initcmd() { [ "$(id -u)" != "0" ] || fail "this command as root is not permitted" @@ -104,11 +98,12 @@ git_init() fail "${PWD}: cannot git-tag ${projectname}/${version}" } -execute_command() +excmd() { lbmkcmd="${buildpath}/${option}" + echo "TEST: $lbmkcmd" [ -f "${lbmkcmd}" ] || fail "Invalid command. Run: ${linkpath} help" - "${lbmkcmd}" $@ || fail "execute_command: ${lbmkcmd} ${@}" + shift 1; "$lbmkcmd" $@ || fail "excmd: ${lbmkcmd} ${@}" } usage() -- cgit v1.2.1