Make the is_number regex accept numbers beginning with -0

Also ends up simpler, too - originally I was trying to avoid accepting
e.g. "+0" or "-0" but that's not really a big deal.

Fixes #14
This commit is contained in:
Oliver Jowett 2015-02-08 22:44:02 +00:00
parent a49b5b8830
commit b313834338

View file

@ -133,7 +133,7 @@ is_ipaddrish_or_empty() {
} }
is_number() { is_number() {
if echo "$1" | grep -Eq '^(0|[+-]?[1-9][0-9]*)(\.[0-9]+)?$'; then return 0; else return 1; fi if echo "$1" | grep -Eq '^([+-]?[0-9][0-9]*)(\.[0-9]+)?$'; then return 0; else return 1; fi
} }
is_number_or_empty() { is_number_or_empty() {