From 514c573b4d3bc739b3d9e7455f86e14c753d4f00 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Mon, 27 Nov 2023 13:51:00 +0100 Subject: [PATCH] download: improve help. This commit corrects linelength (this should have no functional impact) and adds exit codes Signed-off-by: Denis 'GNUtoo' Carikli Acked-by: Adrien 'neox' Bourmault neox: wrote the commit message --- download | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/download b/download index e94f034..181dae6 100755 --- a/download +++ b/download @@ -28,6 +28,8 @@ set -u -e ./resources/scripts/misc/versioncheck +. resources/scripts/misc/sysexits.sh + # set this when you want to modify each coreboot tree # for example, you want to test custom patches # NODELETE= ./download coreboot @@ -51,7 +53,9 @@ list_packages() { help() { cat <<- EOF - USAGE: ./download + Usage: + ./download + ./download --help possible values for 'package': $(list_packages) @@ -76,18 +80,21 @@ help() { } die() { + ret="$1" + shift 1 + printf 'Error: %s\n' "${@}" 1>&2 - exit 1 + exit "${ret}" } if [ $# -lt 1 ]; then help - die "Please specify arguments." + die "${EX_USAGE}" "Please specify arguments." fi package="${1}" shift 1 -[ "${package}" = help ] && help && exit 0 +[ "${package}" = "--help" ] && help && exit 0 if [ "${package}" = "all" ]; then for script in resources/packages/*/download; do @@ -100,7 +107,9 @@ if [ "${package}" = "all" ]; then exit 0 elif [ ! -f "resources/packages/${package}/download" ]; then help - die "Invalid package '${package}'. See: './download help'." + die "${EX_USAGE}" \ + "Invalid package '${package}'." \ + " See: './download --help'." fi if [ $# -lt 1 ]; then