]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
scripts/sortman: Add script to sort manual pages in book order
authorAlejandro Colomar <alx@kernel.org>
Sat, 12 Aug 2023 22:34:34 +0000 (00:34 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sat, 12 Aug 2023 23:34:00 +0000 (01:34 +0200)
`LC_COLLATE=en_US.UTF-8` is needed to collate pages like _exit(3) next
to exit(3), instead of having all pages with a leading underscore
grouped at the beginning of a section.

intro(*), of course, is the fist page of each section, and subsections
go after the last page in the main corresponding section.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
scripts/sortman [new file with mode: 0755]

diff --git a/scripts/sortman b/scripts/sortman
new file mode 100755 (executable)
index 0000000..5835456
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Copyright 2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+export LC_COLLATE=en_US.UTF-8;
+
+sed   -E '/\/intro./ s/.*\.([1-8])$/\10\t&/' \
+| sed -E '/\/intro./!s/.*\.([1-8])$/\11\t&/' \
+| sed -E '/\/intro./!s/.*\.([1-8].+)/\1\t&/' \
+| sort \
+| cut -f2;