From: Steven Baltakatei Sandoval Date: Mon, 22 May 2023 23:23:23 +0000 (+0000) Subject: chore(unitproc/bkt-checkInt):Use 'must' instead of 'try' X-Git-Tag: 0.8.2^2~10 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/34facc2da6534c20f67105591583bc213b1fc4a1?ds=inline;hp=4292743fe100a567fcdced502c499564dce707c3 chore(unitproc/bkt-checkInt):Use 'must' instead of 'try' - note: Also put regular expression test input in quotes. --- diff --git a/unitproc/bkt-checkInt b/unitproc/bkt-checkInt index cfe396e..0922a14 100644 --- a/unitproc/bkt-checkInt +++ b/unitproc/bkt-checkInt @@ -5,7 +5,7 @@ #===BEGIN Declare local script functions=== yell() { echo "$0: $*" >&2; } # print script path and all args to stderr die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status -try() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails +must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails checkInt() { # Desc: Checks if arg is integer # Usage: checkInt arg @@ -13,7 +13,7 @@ checkInt() { # Output: - return code 0 (if arg is integer) # - return code 1 (if arg is not integer) # Example: if ! checkInt $arg; then echo "not int"; fi; - # Version: 0.0.1 + # Version: 0.0.2 local returnState #===Process Arg=== @@ -22,7 +22,7 @@ checkInt() { fi; RETEST1='^[0-9]+$'; # Regular Expression to test - if [[ ! $1 =~ $RETEST1 ]] ; then + if [[ ! "$1" =~ $RETEST1 ]] ; then returnState="false"; else returnState="true";