From 57adbc6eb1f961ee9116904b667f30efb3f2de4f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 23 Aug 2023 18:56:31 +0100 Subject: unify err functions across scripts include/err.sh this new handling also does mundane things, such as tell you what script b0rked Signed-off-by: Leah Rowe --- lbmk | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'lbmk') diff --git a/lbmk b/lbmk index f759e461..cab3d4bd 100755 --- a/lbmk +++ b/lbmk @@ -24,6 +24,8 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e +. "include/err.sh" + projectname="$(cat projectname)" buildpath="" mode="" @@ -31,8 +33,8 @@ option="" main() { - [ "${0##*/}" = "lbmk" ] && die "Don't run this script directly." - [ $# -lt 1 ] && die "Too few arguments. Try: ${0} help" + [ "${0##*/}" = "lbmk" ] && err "Don't run this script directly." + [ $# -lt 1 ] && err "Too few arguments. Try: ${0} help" buildpath="./resources/scripts/${0##*/}" @@ -41,7 +43,7 @@ main() [ "${mode}" = "help" ] && usage ${0} && exit 0 [ $# -lt 2 ] && usage ${0} && exit 1 if [ "${mode}" = "dependencies" ]; then - install_dependencies $@ || die "Could not install dependencies" + install_dependencies $@ || err "Could not install dependencies" exit 0 else ./resources/scripts/misc/versioncheck @@ -62,13 +64,13 @@ main() *) if [ ! -d "${buildpath}/${mode}" ]; then usage $0 - die "Invalid mode '${mode}'. Run: ${0} help" + err "Invalid mode '${mode}'. Run: ${0} help" elif [ ! -f "${buildpath}/${mode}/${option}" ]; then usage $0 printf "Invalid option for '%s'." ${mode} - die "Run: ${0} ${mode} list'." + err "Run: ${0} ${mode} list'." fi - "${buildpath}/${mode}/${option}" $@ || die "lbmk error" + "${buildpath}/${mode}/${option}" $@ || err "lbmk error" esac ./.gitcheck clean @@ -76,12 +78,12 @@ main() install_dependencies() { - [ -f "resources/dependencies/${2}" ] || die "Unsupported target" + [ -f "resources/dependencies/${2}" ] || err "Unsupported target" aur_notice="" . "resources/dependencies/${2}" - ${pkg_add} ${pkglist} || die "Error installing dependencies" + ${pkg_add} ${pkglist} || err "Error installing dependencies" [ "${aur_notice}" != "" ] && \ printf "You must install these AUR packages: %s\n" \ "${aur_notice}" 1>&2 @@ -120,11 +122,4 @@ listmodes() done } -die() -{ - ./.gitcheck clean - printf "Error: %s\n" "${@}" 1>&2 - exit 1 -} - main $@ -- cgit v1.2.1