Dan Jacobson [EMAIL PROTECTED] writes:
$ echo a|sort -o x -o y
$ ls
y
POSIX allows this behavior, but it's admittedly weird.
I think that option order should not matter, unless POSIX or the
documentation explicitly says otherwise. So I propose the following
patch. While looking into this problem I noticed that sort's -t
option doesn't let you specify a NUL as a field separator (this is a
related issue since 'sort' uses 0 to represent no option specified
yet). Also, the documentation and usage strings incorrectly say
white space several places where they should say blanks. Here's
a patch for these problems.
2003-09-02 Paul Eggert [EMAIL PROTECTED]
* NEWS: sort -t '\0' now uses a NUL tab.
sort option order no longer matters, unless POSIX requires it.
* doc/coreutils.texi (sort invocation): -d now overrides -i.
whitespace - blanks; whitespace isn't correct.
-t '\0' now specifies a NUL tab.
* src/sort.c (usage): Say blanks instead of whitespace,
Similar fixes for many comments.
(TAB_DEFAULT): New constant, so that we can support NUL as
the field separator.
(tab): Now int, not char. Initialize to TAB_DEFAULT.
(specify_sort_size): If multiple sizes are specified, use the largest.
(begfield, limfield): Support NUL tab char.
(set_ordering): Do not let -i override -d.
(main): Report an error if incompatible -o or -t options are given.
Report an error for -t ''. Allow -t '\0' to specify a NUL tab.
Index: NEWS
===
RCS file: /cvsroot/coreutils/coreutils/NEWS,v
retrieving revision 1.124
diff -p -u -r1.124 NEWS
--- NEWS27 Aug 2003 09:18:28 - 1.124
+++ NEWS2 Sep 2003 22:50:50 -
@@ -13,6 +13,12 @@ GNU coreutils NEWS
timestamps to their full nanosecond resolution; microsecond
resolution is the best we can do right now.
+ sort now supports the zero byte (NUL) as a field separator; use -t '\0'.
+ The -t '' option, which formerly had no effect, is now an error.
+
+ sort option order no longer matters for the options -S, -d, -i, -o, and -t.
+ Stronger options override weaker, and incompatible options are diagnosed.
+
** Bug fixes
stat no longer overruns a buffer for format strings ending in `%'
Index: doc/coreutils.texi
===
RCS file: /cvsroot/coreutils/coreutils/doc/coreutils.texi,v
retrieving revision 1.130
diff -p -u -r1.130 coreutils.texi
--- doc/coreutils.texi 17 Aug 2003 17:10:25 - 1.130
+++ doc/coreutils.texi 2 Sep 2003 22:51:09 -
@@ -2969,6 +2969,8 @@ converting to floating point.
@vindex LC_CTYPE
Ignore nonprinting characters.
The @env{LC_CTYPE} locale determines character types.
+This option has no effect if the stronger @option{--dictionary-order}
+(@option{-d}) option is also given.
@item -M
@itemx --month-sort
@@ -2976,7 +2978,7 @@ The @env{LC_CTYPE} locale determines cha
@opindex --month-sort
@cindex months, sorting by
@vindex LC_TIME
-An initial string, consisting of any amount of whitespace, followed
+An initial string, consisting of any amount of blanks, followed
by a month name abbreviation, is folded to UPPER case and
compared in the order @samp{JAN} @samp{FEB} @dots{} @samp{DEC}.
Invalid names compare low to valid names. The @env{LC_TIME} locale
@@ -2989,7 +2991,7 @@ category determines the month spellings.
@cindex numeric sort
@vindex LC_NUMERIC
Sort numerically: the number begins each line; specifically, it consists
-of optional whitespace, an optional @samp{-} sign, and zero or more
+of optional blanks, an optional @samp{-} sign, and zero or more
digits possibly separated by thousands separators, optionally followed
by a decimal-point character and zero or more digits. The @env{LC_NUMERIC}
locale specifies the decimal-point character and thousands separator.
@@ -3085,7 +3087,7 @@ than @var{size}.
@cindex field separator character
Use character @var{separator} as the field separator when finding the
sort keys in each line. By default, fields are separated by the empty
-string between a non-whitespace character and a whitespace character.
+string between a non-blank character and a blank character.
That is, given the input line @[EMAIL PROTECTED] foo bar}}, @command{sort} breaks it
into fields @[EMAIL PROTECTED] foo}} and @[EMAIL PROTECTED] bar}}. The field
separator is
not considered to be part of either the field preceding or the field
@@ -3093,6 +3095,10 @@ following. But note that sort fields th
as @option{-k 2}, or sort fields consisting of a range, as @option{-k 2,3},
retain the field separators present between the endpoints of the range.
+To specify a zero byte (@acronym{ASCII} @sc{nul} (Null) character) as
+the field separator, use the two-character string @samp{\0}, e.g.,
[EMAIL PROTECTED] -t '\0'}.
+
@item -T