bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sort --version-sort


From: Bruce Korb
Subject: Re: sort --version-sort
Date: Wed, 13 Aug 2008 10:46:16 -0700
User-agent: Thunderbird 2.0.0.12 (X11/20071114)

Jim Meyering wrote:
Simon Josefsson <address@hidden> wrote:
Bruce Korb <address@hidden> writes:

Here is the usage text from my latest --sort=version patch (attached),
now that paperwork is in order.
What is the status of this work?  I have wanted to use sort this way
several times but became disappointed that there is no support for it
every time.

The most recent patch I saw was incomplete.
Some of these were missing:
documentation (--help, NEWS, .texi), a proper "log", tests.

Color me confused:


@@ -336,10 +337,11 @@ Ordering options:\n\
   -M, --month-sort            compare (unknown) < `JAN' < ... < `DEC'\n\
   -n, --numeric-sort          compare according to string numerical value\n\
   -R, --random-sort           sort by random hash of keys\n\
+  -V, --version-sort          sort by numeric version (see strverscmp(3C))\n\
       --random-source=FILE    get random bytes from FILE (default 
/dev/urandom)\n\
       --sort=WORD             sort according to WORD:\n\
                                 general-numeric -g, month -M, numeric -n,\n\
-                                random -R\n\
+                                random -R, version -V\n\
   -r, --reverse               reverse the result of comparisons\n\
 \n\
 "), stdout);

what else is needed for "--help"?

I also have a clear recollection about someone volunteering to cover the
ancillary stuff (tests, .text), though an unclear recollection as to who
it was ( #-( - sorry).  And I did write a test anyway (below).

Cheers - Bruce

[[P.S. does anyone know the reason for the ``(exit 1) ; exit 1'' idiom?
  It seems weird and I've not been able to google up an answer.]]

diff --git a/tests/misc/sort-version b/tests/misc/sort-version
new file mode 100755
index 0000000..7410015
--- /dev/null
+++ b/tests/misc/sort-version
@@ -0,0 +1,79 @@
+#!/usr/bin/echo do-not-run-this-directly.-Use-a-shell
+# -*- Mode: shell-script -*-
+
+if test "$VERBOSE" = yes; then
+  set -x
+  sort --version
+fi
+
+. $top_srcdir/tests/test-lib.sh
+
+s_file=sort-ver-src
+g_file=sort-ver-good
+r_file=sort-ver-res
+
+cat > ${s_file} <<- _EOF_
+       string start 5.0.0 end of str
+       string start 5.00.0 end of str
+       string start 5.1.0 end of str
+       string start 5.10.0 end of str
+       string start 5.2.0 end of str
+       string start 5.20.0 end of str
+       string start 5.3.0 end of str
+       string start 5.30.0 end of str
+       string start 5.4.0 end of str
+       string start 5.40.0 end of str
+       string start 5.5.0 end of str
+       string start 5.50.0 end of str
+       string start 5.6.0 end of str
+       string start 5.60.0 end of str
+       string start 5.7.0 end of str
+       string start 5.70.0 end of str
+       string start 5.8.0 end of str
+       string start 5.80.0 end of str
+       string start 5.9.0 end of str
+       string start 5.90.0 end of str
+       _EOF_
+
+
+cat > ${g_file} <<- _EOF_
+       string start 5.00.0 end of str
+       string start 5.0.0 end of str
+       string start 5.1.0 end of str
+       string start 5.2.0 end of str
+       string start 5.3.0 end of str
+       string start 5.4.0 end of str
+       string start 5.5.0 end of str
+       string start 5.6.0 end of str
+       string start 5.7.0 end of str
+       string start 5.8.0 end of str
+       string start 5.9.0 end of str
+       string start 5.10.0 end of str
+       string start 5.20.0 end of str
+       string start 5.30.0 end of str
+       string start 5.40.0 end of str
+       string start 5.50.0 end of str
+       string start 5.60.0 end of str
+       string start 5.70.0 end of str
+       string start 5.80.0 end of str
+       string start 5.90.0 end of str
+       _EOF_
+
+fail=0
+sort --sort=version -o ${r_file} ${s_file}
+
+compare ${g_file} ${r_file} >/dev/null 2>&1
+
+if test $? -eq 0
+then
+    rm -f sort-ver-*
+    (exit 0)
+    exit 0
+fi
+
+exec 1>2
+echo "sorted versions are out of order"
+diff -u ${g_file} ${r_file}
+ls -l sort-ver-*
+(exit 1)
+exit 1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]