Don is precisely correct here.
Curiously enough, I don't know of a utility which uses operands to
identify files for output which also allows multiple output files.
The reason for the introduction of - as a synonym for stdin was to
permit the interposition of stdin between the contents of other files
for utilities like cat. The specific case of "sort -o -" is silly on its
face, since the absence of the -o operand in its entirety would have
exactly the same effect Paul is seeking.
Let's suppose the split(1) utility allowed a sequence of operands to
individually name the split pieces. Were that the case, the synopsis
might be
split [-b byte_count[k|m]] [-a suffix_length] [-l line_count] [file
[name ...]]
If only one name were given, it would be the prefix to which suffixes
were applied. But if more than one name were given, the set of names
would be used without the application of suffixes, and any extra output
would be discarded. For this command, which has a set of operands naming
files for the purpose of output, - would be a synonym for stdout. One
could put the 2nd and 4th lines of a file onto stdout like so:
split -l 1 file /dev/null - /dev/null -
Unless we have a utility which allows a set of operands to specify
output files, the text Paul quotes was in fact overgeneralized; in that
case, we should probably remove the text.
-----Original Message-----
From: Don Cragun [mailto:yyy@xxxxxxxxxxxxxxxxxxxxx]
Sent: Tuesday, August 10, 2004 12:05 PM
To: yyyyyy@xxxxxxxxxxx
Cc: yyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Re: Defect in XCU sort
>Return-Path: <yyyyyyyyyyyyyyyyyyyyyyy@xxxxxxxxxxxxx>
Paul,
I disagree with your analysis. In your example:
sort -o -
the final "-" is an option argument; not an operand. The description of
the -o option says that the output option argument is the name of an
output file to be used instead of standard output. There is nothing
here (nor in the Utility Syntax Guidelines) to indicate that if the name
of an output file option argument is "-" that it should be treated as a
synonym for the process' standard output. There is no reference to the
guidelines (direct or indirect) because they do not apply in this case.
All of sort's operands (if any appear) name input files and the OPERANDS
section on sort clearly specifies that if a file operand is "-" it
refers to standard input; never to standard output.
Cheers,
Don
>Date: Sat, 31 Jul 2004 01:03:40 +0100 (BST)
>From: yyyyyy@xxxxxxxxxxx
>X-Mailing-List: austin-review-l:archive/latest/1814
>
> Defect report from : Paul Eggert , UCLA
>
>(Please direct followup comments direct to
>yyyyyyyyyyyyyy@xxxxxxxxxxxxx)
>
>@ page 871 line 33829 section sort editorial {20040730a}
>
>Problem:
>
>Edition of Specification (Year): 2004
>
>Defect code : 3. Clarification required
>
>Does the command "sort -o -" create a file named "-", or does it write
>to standard output?
>
>The specification for "sort" says that it conforms to the Utility
>Syntax Guidelines, and Guideline 13 says
>
> For utilities that use operands to represent files to be opened
> for either reading or writing, the '-' operand should be used only
> to mean standard input (or standard output when it is clear from
> context that an output file is being specified).
>
>Here, "-" is an operand, so apparently "sort -o -" should write to
>standard output. This is what GNU coreutils 5.2.1 "sort" does.
>
>However, I just checked Solaris 9 "sort" (both /usr/bin/sort and
>/usr/xpg4/bin/sort) and OpenBSD 3.4 "sort", and they both create an
>output file "-". It sounds like the standard is not clear enough here,
>perhaps because of the indirect reference to the Guidelines.
>
>
>Action:
>
>Append the following text after page 871 line 33829:
>
> If "output" is "-", sort shall write to standard output.
|