From bbd58a72f27f270a3f400f9682c2bf0d8826c352 Mon Sep 17 00:00:00 2001 From: Ole Petter Date: Wed, 27 Nov 2019 14:40:21 +0100 Subject: [PATCH] Parse user arguments, before exiting on arguments missing Previously, it was not possible to read the help text, without having defined certain user variables the script needs (like MENDER_ARTIFACT_NAME). Thus reading the usage help-info was sort of tedious. This commit gives the user commands higher priority, which fixes the error. Changelog: None Signed-off-by: Ole Petter --- mender-convert | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mender-convert b/mender-convert index c0dbe58..e732fbb 100755 --- a/mender-convert +++ b/mender-convert @@ -54,6 +54,24 @@ function trap_term() { trap trap_term INT TERM trap trap_exit EXIT +# We only handle a selection of the arguments here, the rest are passed on +# to the sub-scripts. +while (( "$#" )); do + case "$1" in + -h | --help) + show_help + exit 0 + ;; + -v | --version) + show_version + exit 0 + ;; + *) + break; + ;; + esac +done + mender_convert_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) if [ "${mender_convert_dir}" != "${PWD}" ]; then echo "You must execute mender-convert from the root directory: ${mender_convert_dir}" @@ -70,24 +88,6 @@ fi source modules/bootstrap.sh -# We only handle a selection of the arguments here, the rest are passed on -# to the sub-scripts. -while (( "$#" )); do - case "$1" in - -h | --help) - show_help - exit 0 - ;; - -v | --version) - show_version - exit 0 - ;; - *) - break; - ;; - esac -done - mkdir -p work touch work/convert.log