download: improve help.

This commit corrects linelength (this should have no functional impact)
and adds exit codes

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
neox: wrote the commit message
This commit is contained in:
Denis 'GNUtoo' Carikli 2023-11-27 13:51:00 +01:00 committed by Adrien 'neox' Bourmault
parent c410023ea3
commit 514c573b4d
Signed by: neox
GPG Key ID: 2974E1D5F25DFCC8
1 changed files with 14 additions and 5 deletions

View File

@ -28,6 +28,8 @@ set -u -e
./resources/scripts/misc/versioncheck ./resources/scripts/misc/versioncheck
. resources/scripts/misc/sysexits.sh
# set this when you want to modify each coreboot tree # set this when you want to modify each coreboot tree
# for example, you want to test custom patches # for example, you want to test custom patches
# NODELETE= ./download coreboot # NODELETE= ./download coreboot
@ -51,7 +53,9 @@ list_packages() {
help() { help() {
cat <<- EOF cat <<- EOF
USAGE: ./download <PACKAGE> <OPTIONS> Usage:
./download <PACKAGE> <OPTIONS>
./download --help
possible values for 'package': possible values for 'package':
$(list_packages) $(list_packages)
@ -76,18 +80,21 @@ help() {
} }
die() { die() {
ret="$1"
shift 1
printf 'Error: %s\n' "${@}" 1>&2 printf 'Error: %s\n' "${@}" 1>&2
exit 1 exit "${ret}"
} }
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
help help
die "Please specify arguments." die "${EX_USAGE}" "Please specify arguments."
fi fi
package="${1}" package="${1}"
shift 1 shift 1
[ "${package}" = help ] && help && exit 0 [ "${package}" = "--help" ] && help && exit 0
if [ "${package}" = "all" ]; then if [ "${package}" = "all" ]; then
for script in resources/packages/*/download; do for script in resources/packages/*/download; do
@ -100,7 +107,9 @@ if [ "${package}" = "all" ]; then
exit 0 exit 0
elif [ ! -f "resources/packages/${package}/download" ]; then elif [ ! -f "resources/packages/${package}/download" ]; then
help help
die "Invalid package '${package}'. See: './download help'." die "${EX_USAGE}" \
"Invalid package '${package}'." \
" See: './download --help'."
fi fi
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then