From b3bba232ac6e1feff9e506506247aa20cd7f467c Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Mon, 30 Mar 2020 17:32:07 +0100 Subject: usage: take exit code as param thus it can correctly indicate success/fail status instead of always indicating failure. when a user asks for usage with -u|--usage then we should exit in success mode rather than failure as when usage in printed in response to incorrect usage. Gbp-Dch: Short --- functions/arguments.sh | 4 ++-- functions/usage.sh | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'functions') diff --git a/functions/arguments.sh b/functions/arguments.sh index a8dd33251..2c1266f78 100755 --- a/functions/arguments.sh +++ b/functions/arguments.sh @@ -127,7 +127,7 @@ Arguments () fi exit 0 elif [ "${IS_FRONTEND}" = "true" ]; then - Usage + Usage 0 fi ;; @@ -137,7 +137,7 @@ Arguments () ;; -u|--usage) - Usage + Usage 0 shift ;; diff --git a/functions/usage.sh b/functions/usage.sh index 19a91c110..388763895 100755 --- a/functions/usage.sh +++ b/functions/usage.sh @@ -11,6 +11,10 @@ Usage () { + if [ -z "${1}" ]; then + Echo_error "Usage() requires an exit code" + fi + echo "${PROGRAM_NAME} - ${DESCRIPTION}" printf "\nUsage:\n\n" @@ -25,5 +29,5 @@ Usage () echo echo "Try \"${PROGRAM} --help\" for more information." - exit 1 + exit $1 } -- cgit v1.2.3