From d51513033fd63b641d939e5364879248a76d4e7b Mon Sep 17 00:00:00 2001 From: hms Date: Sat, 6 Feb 2021 11:16:29 -0800 Subject: [PATCH] Added try catch code and comments --- refresh-NebulaCA | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/refresh-NebulaCA b/refresh-NebulaCA index b306d20..5f3ce79 100644 --- a/refresh-NebulaCA +++ b/refresh-NebulaCA @@ -7,12 +7,42 @@ # Created By: HMSheets ###################################################### -invalid_args_msg () { - echo "Invalid Parameter(s) Entered: $1" +# Try Catch Functions +function try() +{ + [[ $- = *e* ]]; SAVED_OPT_E=$? + set +e +} + +function throw() +{ + exit $1 +} + +function catch() +{ + export ex_code=$? + (( $SAVED_OPT_E )) && set +e + return $ex_code +} + +function throwErrors() +{ + set -e +} + +function ignoreErrors() +{ + set +e +} + +# Parameter Eval Fuctions +function invalid_args_msg () { + echo "Invalid Parameter(s) Entered" exit } -help_msg () { +function help_msg () { echo "Usage of refresh-NebulaCA : refresh an existing nebula ca" echo " -n|--caname" echo " Name to use for the new CA. Used in the CA cert file and in the filename" @@ -27,6 +57,7 @@ help_msg () { exit } +# Parameter Evaluation while loop POSITIONAL=() while [[ $# -gt 0 ]] do