summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-08-13 23:00:45 +0200
committerAlejandro Colomar <alx@kernel.org>2023-08-14 00:11:24 +0200
commitaab14503ef101d918046aeaa941f226685fe7bf5 (patch)
tree6d5e796f82cb8cf6e8bd609d62e75aa2d8b3e1ee /scripts
parent993910a218af7a8871225edf378c54da0e341cfc (diff)
scripts/sortman: Use version sort
This is to collate correctly pages like the following: man7/iso-8859-1.7 man7/iso-8859-2.7 man7/iso-8859-3.7 man7/iso-8859-4.7 man7/iso-8859-5.7 man7/iso-8859-6.7 man7/iso-8859-7.7 man7/iso-8859-8.7 man7/iso-8859-9.7 man7/iso-8859-10.7 man7/iso-8859-11.7 man7/iso-8859-13.7 man7/iso-8859-14.7 man7/iso-8859-15.7 man7/iso-8859-16.7 Also ignore case, since otherwise a version sort would collate 'Z' before 'a'. We don't need LC_COLLATE anymore. Version sort has some issues for our purpose: underscores and dashes have special (and different) meaning. We want to ignore underscores or dashes that aren't next to digits, so that _exit(2) remains next to exit(2). However, we want to keep them next to digits, such as in iso-8859-1(7), to keep the right order for pages with numbers. For that, we need some extra sed(1) magic. Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca> Cc: Deri James <deri@chuzzlewit.myzen.co.uk> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sortman16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/sortman b/scripts/sortman
index f0926f215..566326f42 100755
--- a/scripts/sortman
+++ b/scripts/sortman
@@ -3,10 +3,12 @@
# 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/.*\.([[:digit:]])/\10\t&/' \
-| sed -E '/\/intro./!s/.*\.([[:digit:]])\>/\11\t&/' \
-| sed -E '/\/intro./!s/.*\.([[:digit:]][[:alnum:]]+)/\1\t&/' \
-| sort \
-| cut -f2;
+sed -E '/\/intro./ s/.*\.([[:digit:]])/\10\t&/' \
+| sed -E '/\/intro./! s/.*\.([[:digit:]])\>/\11\t&/' \
+| sed -E '/\/intro./! s/.*\.([[:digit:]])([[:alnum:]]+)/\12.\2\t&/' \
+| sed -E ' s/\t(.*)/&\n\1/' \
+| sed -E '/\t/ s/([^[:digit:]])[_-]([^[:digit:]])/\1\2/g' \
+| sed -E '/\t/ s/[_-]/_/g' \
+| sed -E '/\t/ {N;s/\n/\t/;}' \
+| sort -fV \
+| cut -f3;