try() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails
checkFlt() {
# Desc: Checks if arg is a float
- # Usage: checkInt arg
+ # Usage: checkFlt arg
# Input: arg: float
# Output: - return code 0 (if arg is float)
# - return code 1 (if arg is not float)
- # Example: if ! checkInt $arg; then echo "not flt"; fi;
- # Version: 0.0.1
+ # Example: if ! checkFlt $arg; then echo "not flt"; fi;
+ # Version: 0.0.2
# Depends: yell(), die(), bash 5.0.3
# Ref/Attrib: JDB https://stackoverflow.com/a/12643073 float regex
local returnState
else
return 1;
fi;
-} # Checks if arg is integer
+} # Checks if arg is float
#===END Declare local script functions===
#==END Define script parameters==
myVar1="foo"; myVar2="bar"; myVar3="baz"; echo "Test 11: Should fail because multiple arguments provided.";
(if checkFlt "$myVar1" "$myVar2" "$myVar3"; then yell "success"; else yell "fail"; fi;) & sleep 1;
+
+myVar1=""; echo "Test 12: Should fil because empty string.";
+(if checkFlt "$myVar1"; then yell "success"; else yell "fail"; fi;) & sleep 1;
#==END test code==
# Author: Steven Baltakatei Sandoval