From cd054a10abe015ce91448a555a65387c0f6ff5e8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 18 Apr 2017 11:07:57 -0400 Subject: [PATCH] Document a pipe-to-sort and justify the lack of a special CIDR sort. --- doc/man1/hath.1 | 15 +++++++++++++++ test/shell/manpage-sort.test | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 test/shell/manpage-sort.test diff --git a/doc/man1/hath.1 b/doc/man1/hath.1 index 488cebb..8597835 100644 --- a/doc/man1/hath.1 +++ b/doc/man1/hath.1 @@ -101,6 +101,21 @@ Use the \(dqdig\(dq command to look up the PTR records for a netblock: 4.0.41.198.in-addr.arpa. 897 IN PTR a.root-servers.net. 6.0.41.198.in-addr.arpa. 900 IN PTR rs.internic.net. .fi +.P +Sort the \(dqreduced\(dq output: + +.nf +.I $ echo \(dq192.168.0.100/24 192.167.1.200/24\(dq | hath reduced | sort +192.167.1.200/24 +192.168.0.100/24 +.fi + +Sorting the output only makes sense for the \(dqreduced\(dq mode. In +that mode, two output CIDRs cannot have same the numeric address and a +different mask: one of them would contain the other, and the redundant +one would be eliminated. As a result, there is no need for a special +CIDR sort; the lexical or numerical sort provided by the \(dqsort\(dq +utility will produce the same results as a more intelligent sort. .SH OPTIONS .IP \fB\-\-barriers\fR,\ \fB\-b\fR diff --git a/test/shell/manpage-sort.test b/test/shell/manpage-sort.test new file mode 100644 index 0000000..56dd025 --- /dev/null +++ b/test/shell/manpage-sort.test @@ -0,0 +1,7 @@ +# Test the pipe-to-sort example from the man page. + +echo "192.168.0.100/24 192.167.1.200/24" | dist/build/hath/hath reduced | sort +>>> +192.167.1.200/24 +192.168.0.100/24 +>>>= 0 -- 2.43.2