]> gitweb.michael.orlitzky.com - hath.git/blobdiff - doc/man1/hath.1
Add a --sort flag to hath and document/test why it was needed after all.
[hath.git] / doc / man1 / hath.1
index 0316c56a3ada9fc131940a8c91d541daeda2aa25..69b362fe17079601c155d330918b91e48e61532c 100644 (file)
@@ -119,6 +119,7 @@ Without \fB\-\-barriers\fR, you can match things you shouldn't:
 .fi
 
 Using \fB\-\-barriers\fR can prevent this:
+
 .nf
 .I $ echo 127.0.0.100 | grep -P $(echo 127.0.0.1/32 | hath -b)
 .I $ echo $?
@@ -127,10 +128,47 @@ Using \fB\-\-barriers\fR can prevent this:
 
 But, this may also cause the regex to match something that isn't an IP
 address:
+
 .nf
 .I $ echo x127.0.0.1x | grep -Po $(echo 127.0.0.1/32 | hath -b)
 x127.0.0.1x
 .fi
+.IP \fB\-\-normalize\fR,\ \fB\-n\fR
+(reduced mode only)
+
+Normalize the output representation of CIDRs by zeroing the host
+bits. This option only has an effect in \(dqreduced\(dq mode, because
+in the \(dqduped\(dq or \(dqdiffed\(dq modes, it would be confusing to
+see CIDRs that you did not input in the first place being removed.
+
+.nf
+.I $ echo 127.0.0.1/8 | hath reduced
+127.0.0.1/8
+.I $ echo 127.0.0.1/8 | hath reduced --normalize
+127.0.0.0/8
+.fi
+.IP \fB\-\-sort\fR,\ \fB\-s\fR
+(reduced mode only)
+
+Sort the output CIDRs numerically by octet. The \(dqsort\(dq utility
+doesn't understand IP addresses, so the default pipe-to-sort approach
+fails in some cases:
+
+.nf
+.I $ echo \(dq10.0.121.32/28 10.0.93.248/29\(dq | hath reduced | sort
+10.0.121.32/28
+10.0.93.248/29
+.I $ echo \(dq10.0.121.32/28 10.0.93.248/29\(dq | hath reduced | sort -n
+10.0.121.32/28
+10.0.93.248/29
+.fi
+
+That failure justifies adding the additional option to hath:
+
+.nf
+.I $ echo \(dq10.0.121.32/28 10.0.93.248/29\(dq | hath reduced --sort
+10.0.93.248/29
+10.0.121.32/28
 .SH BUGS
 
 Send bugs to michael@orlitzky.com.