From 1d58ef8858dd8a97702944f1884883a82ccd4fd8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 16 Apr 2017 22:14:03 -0400 Subject: [PATCH] Document and test the new --normalize flag. --- doc/man1/hath.1 | 17 +++++++++++++++++ test/shell/manpage-normalize.test | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/shell/manpage-normalize.test diff --git a/doc/man1/hath.1 b/doc/man1/hath.1 index 0316c56..488cebb 100644 --- a/doc/man1/hath.1 +++ b/doc/man1/hath.1 @@ -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,26 @@ 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 .SH BUGS Send bugs to michael@orlitzky.com. diff --git a/test/shell/manpage-normalize.test b/test/shell/manpage-normalize.test new file mode 100644 index 0000000..6cd4948 --- /dev/null +++ b/test/shell/manpage-normalize.test @@ -0,0 +1,13 @@ +# Test the --normalize examples from the man page. + +# The "control group" example. +echo 127.0.0.1/8 | dist/build/hath/hath reduced +>>> +127.0.0.1/8 +>>>= 0 + +# The --normalize flag in action. +echo 127.0.0.1/8 | dist/build/hath/hath reduced --normalize +>>> +127.0.0.0/8 +>>>= 0 -- 2.44.2