From 383ed25682cbea2444223f08e7e00b08024b4bab Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 18 Apr 2018 23:42:04 +0200 Subject: argument_error(): Exit after printing I previously changed this to only print instead of print and exit because that allowed me to show all errors for multiple missing required arguments. The trouble was, the script would just keep running afterward even with missing arguments. To make things simpler, don't bother tracking all our requirements and just fail fast after the first error so we don't end up executing the program without all required data. --- redprine | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/redprine b/redprine index 12cda44..7fb277d 100755 --- a/redprine +++ b/redprine @@ -175,16 +175,11 @@ function update_cache_with_new_pulls () { # update_cache_with_new_pulls "$pr_json" -function echo_error () { - local message="$1" - - echo "redprine: error: $message" 1>&2 -} function exit_with_error () { local message="$1" - echo_error "$message" + echo "redprine: error: $message" 1>&2 exit 1 } @@ -192,7 +187,7 @@ function exit_with_error () { function argument_error () { local flag="$1" - echo_error "Required argument '$flag' not provided, try --help" + exit_with_error "Required argument '$flag' not provided, try --help" } function check_required_argument () { -- cgit v1.2.3