The is_digits() function provided by the "is" module can be used to
determine if an input consists of only digits. However, it cannot be
used to validate inputs that may be prefixed with a sign.
This commit adds the is_int() function, which can be used to validate
numeric inputs that may be prefixed with a sign.
return 0
}
+is_int() {
+ local str="$1"
+
+ if [[ "$str" =~ ^[+-]{,1}[0-9]+$ ]]; then
+ return 0
+ fi
+
+ return 1
+}
+
is_digits() {
local str="$1"