Skip to content

Commit

Permalink
Small syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
covert8 committed Jul 18, 2023
1 parent 9957327 commit 190f603
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,11 @@ validate_ip() {
local ip="${1:?ip is missing}"
local stat=1

validate_ipv4 "$ip"
if [[ $? -eq 0 ]]; then
stat=0
else
validate_ipv6 "$ip"
stat=$?
fi
if validate_ipv4 "$ip"; then
stat=0
else
stat=$(validate_ipv6 "$ip")
fi

return $stat
}
Expand Down Expand Up @@ -239,16 +237,13 @@ validate_ipv4() {
validate_ipv6() {
local ip="${1:?ip is missing}"
local stat=1

local full_address_regex='^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'
local short_address_regex='^((([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6}::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6})$'


if [[ $ip =~ $full_address_regex || $ip =~ $short_address_regex || $ip == "::" ]]; then
stat=0
fi

echo $stat
return $stat
}

########################
Expand Down

0 comments on commit 190f603

Please sign in to comment.