On Apr 28, 2010, at 07:25 AM, Richard L. Hamilton wrote:

>> Why are there 2 separate binaries for /usr/bin/sort
>> and
>> /usr/xpg4/bin/sort? From looking at it the only
>> difference is option
>> -c.
>> sort(1) says:
>>  /usr/bin/sort
>> -c    Checks that the single input file is ordered
>> as speci-
>> fied  by  the  arguments and the collating
>> sequence of
>> the current locale. The exit code is set
>> and no output
>>          is produced unless the file is out of sort.
>> pg4/bin/sort
>> -c              Same as /usr/bin/sort except  no
>>  output  is
>>                   produced under any circumstances.
>> problem? I thought error messages are
>> notaninterface? Or is this the exception of the
>> common rule?

I thought I had already responded to this issue earlier, but I may have
just responded to Olga instead of the entire list...

The format and exact contents of diagnostic messages are usually not
specified by the standards (i.e. not-an-interface), but the fact that a
diagnostic message is or is not written to STDERR is an interface.

> 
> The code in question is at
> http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/sort/common/check.c#203
> 
> which looks like it enables messages for the non-xpg4 in the case of either
> -c
> or
> -c -u
> options.
> 
> http://www.opengroup.org/onlinepubs/9699919799/utilities/sort.html
> 
> shows something new: -c for error messages and -C (capital C) same but with
> no error messages:
>> -c
>>  Check that the single input file is ordered as specified by the arguments
>> and the collating sequence of the current locale. Output shall not be sent
>> to standard output. The exit code shall indicate whether or not disorder
>> was detected or an error occurred. If disorder (or, with -u, a duplicate key)
>> is detected, a warning message shall be sent to standard error indicating
>> where the disorder or duplicate key was found.
>> -C
>>   Same as -c, except that a warning message shall not be sent to standard
>> error if disorder or, with -u, a duplicate key is detected.
> 
> As far as I can tell, the current code does not implement the -C (capital C)
> option.
> 
> The availability of both those options would comply with the latest standard,
> AFAIK, and would resolve the difference between /usr/bin/sort and
> /usr/xpg4/bin/sort (by allowing both behaviors by command line option, and
> with the existing /usr/bin/sort behavior effectively the default (i.e. if one
> uses -c rather than the new -C).
> 
> That's my take, anyway...

Earlier versions of the standard described the -c (lower-case) option as:
        Check that the single input file is ordered as specified
        by the arguments and the collating sequence of the current
        locale. No output shall be produced; only the exit code
        shall be affected.
and did not specify the -C (upper-case) option.  The "No output shall
be produced" covers both STDOUT and STDERR; so the current source
matches the earlier standards.  Oracle has not announced any plans to
implement the changes needed to align with the current standard.  (And
Sun laid off its POSIX/UNIX standards conformance group over a year ago.)

 - Don

_______________________________________________
shell-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/shell-discuss

Reply via email to