simpler regex suggested by @MichaIng

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2020-06-15 21:21:40 +01:00
parent 011fa8c6ea
commit fe30ce10d3
No known key found for this signature in database
GPG key ID: 872950F3ECF2B173

View file

@ -1018,7 +1018,7 @@ valid_ip() {
local stat=1 local stat=1
# If the IP matches the format xxx.xxx.xxx.xxx (optional port of range #0-65536), also ensure string ends with 0-9 # If the IP matches the format xxx.xxx.xxx.xxx (optional port of range #0-65536), also ensure string ends with 0-9
if [[ "${ip}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#{0,1}[0-9]{0,5}$ && "${ip}" =~ ^.*[0-9]$ ]]; then if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(#[0-9]{1,5})?$ ]]; then
# Save the old Internal Field Separator in a variable # Save the old Internal Field Separator in a variable
OIFS=$IFS OIFS=$IFS
# and set the new one to a dot (period) # and set the new one to a dot (period)