On 2023-08-28 06:17, Alejandro Colomar wrote:
Hi Brian,
On 2023-08-22 01:45, Brian Inglis wrote:
I am in favour of all punctuation being treated as word spaces and sorting
"cat ..." before "cat..." but find the real orders more evocative and easier to
decide about than examples.
Here's an excerpt of how treating - and _ as spaces looks like. I think
it's a reasonable order. Should I apply that diff?
Cheers,
Alex
$ git diff
diff --git a/scripts/sortman b/scripts/sortman
index a8f70bab5..6d1d92f09 100755
--- a/scripts/sortman
+++ b/scripts/sortman
@@ -9,7 +9,7 @@ sed -E '/\/intro./ s/.*\.([[:digit:]])/\10\t&/' \
| sed -E ' s/\t(.*)/&\n\1/' \
| sed -E '/\t/ s/\.[[:digit:]]([[:alpha:]][[:alnum:]]*)?\>.*//' \
| sed -E '/\t/ s/\/[_-]*/\//g' \
-| sed -E '/\t/ s/[_-]/_/g' \
+| sed -E '/\t/ s/[_-]/ /g' \
| sed -E '/\t/ {N;s/\n/\t/;}' \
| sort -fV -k1,2 \
| cut -f3;
$ touch man8/ld-z.8
$ touch man8/ld.8
$ find man8 | ./scripts/sortman
man8/intro.8
man8/iconvconfig.8
man8/ld.8
man8/ld-linux.8
man8/ld-linux.so.8
man8/ld-z.8
man8/ld.so.8
man8/ldconfig.8
man8/nscd.8
man8/sln.8
man8/tzselect.8
man8/zdump.8
man8/zic.8
man8
Looks better, but should your sort *key* field instance also drop the section
suffix (already in prefix) and also treat "." as space?
Where would you expect to see ld.so?
Also, in `sed`, instead of cloning the line, at the start of a series of
executions, make them all into a single inline command script, start with `h` to
*hold* the input line, and end with `G` instead of `N` to append '\n' then the
held line, convert to `\t`, drop the braces, and you can skip the then redundant
tests, something like the following should get you close (tried it earlier, now
sadly already gone from history):
| sed -E '
h
/\/intro./ s/.*\.([[:digit:]])/\10\t&/
s/\.[[:digit:]]([[:alpha:]][[:alnum:]]*)?\>.*//
s/\/[_-]*/\//g
s/[_-]/_/g
s/[_-]/ /g
G
s/\n/\t/
' \
| ...
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut
-- Antoine de Saint-Exupéry