ip2cidr

Small and simple program for converting a netmask into a CIDR
git clone https://noxz.tech/git/ip2cidr.git
Log | Files | README | LICENSE

commit: 366289f96b2cea63126cad3060de01bba3614f51
parent: 6f809ffdd935fd0bf86f6a14d3087829569bf311
author: z0noxz <chris@noxz.tech>
date:   Fri, 3 Aug 2018 22:05:27 +0200
fix formatting and cidr bounds {1..32} instead of {0..32}
Mip2cidr6+++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ip2cidr b/ip2cidr
@@ -48,14 +48,14 @@ function isip {
             ${ip[2]} -le 255 &&\
             ${ip[3]} -le 255 \
         ]]; then
-	    return 0
-	fi
+            return 0
+        fi
     fi
     return 1
 }
 
 # check if input already is a CIDR
-if [[ $1 =~ ^[0-9]{1,2}$ && ${1} -le 32 ]]; then
+if [[ $1 =~ ^[0-9]{1,2}$ && $1 -le 32 && $1 -gt 0 ]]; then
     echo "$1"
     exit
 fi