added disp function and use it

This commit is contained in:
2022-11-18 13:43:10 +01:00
parent c5a43a3942
commit 4a975db1c0
10 changed files with 184 additions and 74 deletions

View File

@@ -15,13 +15,13 @@ isipv4 ()
if [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]; then
if [[ -t 1 ]]; then
echo "The given IPv4 is valid."
disp "The given IPv4 is valid."
fi
return 0
fi
fi
if [[ -t 1 ]]; then
echo "The given parameter is NOT a valid IPv4."
disp "The given parameter is NOT a valid IPv4."
fi
return 1
}
@@ -37,12 +37,12 @@ isipv6 ()
local regex='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$'
if [[ $ip =~ $regex ]]; then
if [[ -t 1 ]]; then
echo "The given IPv6 is valid."
disp "The given IPv6 is valid."
fi
return 0
fi
if [[ -t 1 ]]; then
echo "The given parameter is not a valid IPv6."
disp "The given parameter is not a valid IPv6."
fi
return 1
}