From 4c75f80e6763490d5bcb0e0a460b096a3292ae61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= Date: Thu, 23 Apr 2020 16:38:59 +0200 Subject: [PATCH] Use descriptive parameter names for Usage() --- frontend/lb | 2 +- functions/arguments.sh | 4 ++-- functions/usage.sh | 19 ++++++++++++++----- scripts/build/chroot_apt | 2 +- scripts/build/chroot_archives | 4 ++-- scripts/build/chroot_debianchroot | 2 +- scripts/build/chroot_devpts | 2 +- scripts/build/chroot_dpkg | 2 +- scripts/build/chroot_hostname | 2 +- scripts/build/chroot_hosts | 2 +- scripts/build/chroot_proc | 2 +- scripts/build/chroot_resolv | 2 +- scripts/build/chroot_selinuxfs | 2 +- scripts/build/chroot_sysfs | 2 +- scripts/build/chroot_sysv-rc | 2 +- scripts/build/chroot_tmpfs | 2 +- scripts/build/clean | 4 ++-- scripts/build/config | 2 +- 18 files changed, 34 insertions(+), 25 deletions(-) diff --git a/frontend/lb b/frontend/lb index 4f4aa2ead..08aae45a2 100755 --- a/frontend/lb +++ b/frontend/lb @@ -25,7 +25,7 @@ Arguments frontend "${@}" eval set -- "${REMAINING_ARGS}" if [ -z "${1}" ]; then - Usage 1 + Usage --fail fi COMMAND="${1}" diff --git a/functions/arguments.sh b/functions/arguments.sh index 2c1266f78..b10a82532 100755 --- a/functions/arguments.sh +++ b/functions/arguments.sh @@ -127,7 +127,7 @@ Arguments () fi exit 0 elif [ "${IS_FRONTEND}" = "true" ]; then - Usage 0 + Usage --exit fi ;; @@ -137,7 +137,7 @@ Arguments () ;; -u|--usage) - Usage 0 + Usage --exit shift ;; diff --git a/functions/usage.sh b/functions/usage.sh index 388763895..4c4f585dc 100755 --- a/functions/usage.sh +++ b/functions/usage.sh @@ -11,10 +11,6 @@ Usage () { - if [ -z "${1}" ]; then - Echo_error "Usage() requires an exit code" - fi - echo "${PROGRAM_NAME} - ${DESCRIPTION}" printf "\nUsage:\n\n" @@ -29,5 +25,18 @@ Usage () echo echo "Try \"${PROGRAM} --help\" for more information." - exit $1 + case $1 in + --fail) + exit 1 + ;; + --exit) + exit 0 + ;; + "") + : + ;; + *) + Echo_error "Unexpected parameter to Usage(): $1" + ;; + esac } diff --git a/scripts/build/chroot_apt b/scripts/build/chroot_apt index cbb0baff0..6d974f1b5 100755 --- a/scripts/build/chroot_apt +++ b/scripts/build/chroot_apt @@ -217,6 +217,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_archives b/scripts/build/chroot_archives index f36f79ccd..e170d5be0 100755 --- a/scripts/build/chroot_archives +++ b/scripts/build/chroot_archives @@ -23,7 +23,7 @@ _ACTION="${2}" shift 2 if ! In_list "${_PASS}" "binary" "chroot" "source"; then - Usage 1 + Usage --fail fi # Processing arguments and configuration files @@ -441,6 +441,6 @@ case "${_ACTION}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_debianchroot b/scripts/build/chroot_debianchroot index 3a2050565..e7f32b4f6 100755 --- a/scripts/build/chroot_debianchroot +++ b/scripts/build/chroot_debianchroot @@ -67,6 +67,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_devpts b/scripts/build/chroot_devpts index 0083548ea..7d55ca9e7 100755 --- a/scripts/build/chroot_devpts +++ b/scripts/build/chroot_devpts @@ -63,6 +63,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_dpkg b/scripts/build/chroot_dpkg index 32460c298..598b50075 100755 --- a/scripts/build/chroot_dpkg +++ b/scripts/build/chroot_dpkg @@ -84,6 +84,6 @@ EOF ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_hostname b/scripts/build/chroot_hostname index d90e3710d..a209bcfba 100755 --- a/scripts/build/chroot_hostname +++ b/scripts/build/chroot_hostname @@ -77,6 +77,6 @@ EOF ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_hosts b/scripts/build/chroot_hosts index 53fa4f7d4..27090f05f 100755 --- a/scripts/build/chroot_hosts +++ b/scripts/build/chroot_hosts @@ -83,6 +83,6 @@ EOF ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_proc b/scripts/build/chroot_proc index 4c845498e..3a9aba57f 100755 --- a/scripts/build/chroot_proc +++ b/scripts/build/chroot_proc @@ -67,6 +67,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_resolv b/scripts/build/chroot_resolv index b035c5698..1918856cc 100755 --- a/scripts/build/chroot_resolv +++ b/scripts/build/chroot_resolv @@ -95,6 +95,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_selinuxfs b/scripts/build/chroot_selinuxfs index 9bab5eb05..2916679d6 100755 --- a/scripts/build/chroot_selinuxfs +++ b/scripts/build/chroot_selinuxfs @@ -64,6 +64,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_sysfs b/scripts/build/chroot_sysfs index f95cacb43..070dd6eda 100755 --- a/scripts/build/chroot_sysfs +++ b/scripts/build/chroot_sysfs @@ -61,6 +61,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_sysv-rc b/scripts/build/chroot_sysv-rc index 5316ff212..bcf86a74d 100755 --- a/scripts/build/chroot_sysv-rc +++ b/scripts/build/chroot_sysv-rc @@ -73,6 +73,6 @@ EOF ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/chroot_tmpfs b/scripts/build/chroot_tmpfs index c1cbad68f..ae1d0f82c 100755 --- a/scripts/build/chroot_tmpfs +++ b/scripts/build/chroot_tmpfs @@ -66,6 +66,6 @@ case "${1}" in ;; *) - Usage 1 + Usage --fail ;; esac diff --git a/scripts/build/clean b/scripts/build/clean index 82bf052f6..1e10e35f6 100755 --- a/scripts/build/clean +++ b/scripts/build/clean @@ -144,7 +144,7 @@ do ;; -u|--usage) - Usage 0 + Usage --exit ;; -v|--version) @@ -153,7 +153,7 @@ do ;; *) - Usage 1 + Usage --fail ;; esac done diff --git a/scripts/build/config b/scripts/build/config index dbe01d585..c4fd6cf2a 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -294,7 +294,7 @@ Local_arguments () ;; -u|--usage) - Usage 0 + Usage --exit shift ;;