- note: Also put regular expression test input in quotes.
#===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
#===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
checkInt() {
# Desc: Checks if arg is integer
# Usage: checkInt arg
# 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;
# 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;
local returnState
#===Process Arg===
local returnState
#===Process Arg===
fi;
RETEST1='^[0-9]+$'; # Regular Expression to test
fi;
RETEST1='^[0-9]+$'; # Regular Expression to test
- if [[ ! $1 =~ $RETEST1 ]] ; then
+ if [[ ! "$1" =~ $RETEST1 ]] ; then
returnState="false";
else
returnState="true";
returnState="false";
else
returnState="true";