Re: Support for `tail -10', etc. even when conforming to POSIX.1-2001

2005-04-27 Thread Paul Eggert
Thanks for your review.

Eric Blake [EMAIL PROTECTED] writes:

 Hmm - if coreutils ever supplies renice, that would also be a candidate
 for supporting obsolescent usages.

Yes, I suppose so.

 Also, the Austin group minutes mention that uniq could support '+'
 as an option separator

That is the second part of that report: it talks about possible future
changes to the standard.  I decided not to implement that for now,
partly because it's hard to track a standard that's not written yet,
and partly because when the new standard comes out we'll have to
decide whether we want to support _three_ standard variants (1992,
2001, and 2006, say?) or cut it down to two, and I'd rather not worry
about that yet.

 does that mean that `uniq +c' should behave
 as `uniq -c' or as `uniq ./+c'?

No, it would support only uniq +10 as an alias for uniq -s 10, as
described in the 1997 edition here:
http://www.opengroup.org/onlinepubs/007908799/xcu/uniq.html.
Likewise for sort and tail: it's only a very few options that are
affected (where the old standard says they have to be interpreted as
options and the 2001 standard says they have to be interpreted as file
names).

 [EMAIL PROTECTED] -S @var{string}
 [EMAIL PROTECTED] [EMAIL PROTECTED]

 Shouldn't this be [EMAIL PROTECTED] [EMAIL PROTECTED]'?

Either metanotation is accurate, as the string can be empty.  I
thought it simpler to omit the brackets, but I suppose I might be
talking into the other way.  Is there precedent either way in the
manual?

 +For example, use @samp{sort ./+2} or @samp{sort -k 3} rather than
 +the ambiguous @samp{sort +2}.

 Shouldn't the second example be [EMAIL PROTECTED] -k 2}' for consistency?

No, the obsolete notation is origin-0 and the standard one is
origin-1, so the obsolete +2 is equivalent to the standard -k3.

 +For example, use @samp{touch ./12312359 main.c} or @samp{touch -t
 +12312359 main.c} rather than the ambiguous @samp{touch 12312359 main.c}.
 +

 Would an example of `touch 1231235999 main.c' compared to `touch -t
 9912312359 main.c' vs. `touch -5 ./1231235999 main.c' be helpful?

Naaah.  It might encourage people to use 2-digit years.

 +For compatibility @command{nice} also supports an obsolete
 +option syntax @[EMAIL PROTECTED]  New scripts should use
 [EMAIL PROTECTED] @var{adjustment}} instead.

 Is it worth showing the difference between `nice -10' and `nice --10'?

Similarly, I'd rather not document the obsolete syntax to that level
of detail; it might encourage people to use it.

 -#define COMMON_SHORT_OPTIONS -bcdfgik:mMno:rsS:t:T:uz
 +static char const short_options[] = -bcdfgik:mMno:rsS:t:T:uy:z;

 `info coreutils sort' and `sort --help' do not mention `sort -y', and you
 just changed its argument from being optional in older POSIX to being
 required.

The C code that implements '-y' works around this apparent change, so
if you combine the change to the C code with the change to the short
options, the user won't notice the difference.  At least that's the
theory.


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Support for `tail -10', etc. even when conforming to POSIX.1-2001

2005-04-26 Thread Paul Eggert
I installed this patch to coreutils to bring back support for commonly
used commands like tail -10 even when conforming to POSIX.1-2001, as
a compatible extension to POSIX.  There are still a few remaining
trouble spots (see the NEWS patch below) but most of the problems
should be resolved to everyone's satisfaction.  Thanks to everyone who
pushed the POSIX committee (and me :-) to get this matter clarified
and resolved.

2005-04-26  Paul Eggert  [EMAIL PROTECTED]

Restore support for usages like head -1 and tail -1,
even when conforming to POSIX 1003.1-2001.
Fix bug with POSIXLY_CORRECT=1 fold file -3.
join now supports a NUL field separator, e.g., join -t '\0'.
join now detects and reports incompatible options, e.g.,
join -t x -t y,
* NEWS: Document this.
* doc/coreutils.texi (Standards conformance): Do not mention head -10,
since it now works the same regardless of POSIX version.
(od invocation): -w N - -w[N].
(pr invocation): -S STRING - -SSTRING.
(fold invocation): -WIDTH works even when conforming to POSIX
1003.1-2001.
(head invocation, tail invocation): Likewise for -NUM.
(split invocation): Likewise for -LINES.
(uniq invocation): Likewise for -N.
(expand invocation, unexpand invocation): Likewise for -TAB.
(nice invocation): Likewise for -ADJUSTMENT.
(sort invocation): Clarify explanation of +N option.
(uniq invocation): Likewise.
(join invocation): Remove special case for --help, --version.
(touch invocation): Clarify explanation of date options.
(Options for date): -I timespec - -I[timespec].
* src/date.c: Remove posixver.h and its uses.
(COMMON_SHORT_OPTIONS): Remove.
(short_options): New constant.
(short_options, usage): -I now always takes an optional arg.
* src/expand.c: Remove posixver.h and its uses.
(shortopts): New constant.  -DIGIT now always takes an optional arg.
(main): Revamp parsing of -DIGIT to let parse_tab_stops handle it.
Don't complain about -DIGIT.
* src/fold.c: Remove posixver.h and its uses.
(shortopts): New constant.  -DIGIT now always takes an optional arg.
(main): Don't preprocess arg list; that was buggy.  Use method
similar to expand.
* src/head.c: Remove posixver.h and its uses.
(header_mode_option): Remove.
(main): Don't complain about obsolete -NUM args.
* src/join.c: Remove posixver.h and its uses.
(obsolete_usage): Remove.
(join_field_1, join_field_2): Initialize to SIZE_MAX to indicate
they haven't been set yet.
(tab): Now int, not char.  Initialize to -1 to indicate white space
separates columns, so that we can use NUL as a separator.
All uses changed.
(OBSOLETE_LONG_OPTIONS, get_option): Remove.
(string_to_join_field): Remove ERR_MSG_FMT arg; a single format
suffices.  Use xstrtoul for sizes; it suffices.
(decode_field_spec): Report an error and exit on failure.  Return void,
not bool.
(add_field_list): Likewise.
(set_join_field): New function.
(enum operand_status): New enum.
(add_file_name): New args OPERAND_STATUS, JOPTION_COUNT,
PREV_OPTC_STATUS, OPTC_STATUS to handle the bewildering array of
possibilities with obsolete option parsing.
(main): Use it.  Do not depend on POSIX version.
Check for conflicting options.  Parse obsolete options -j1 and -j2
so that it is a pure extension to POSIX 1003.1-2001.
Allow '-t\0' to specify a NUL tab, stealing the code from 'sort'.
* src/nice.c: Remove posixver.h and its uses.
(main): Always support -NUM option.
* src/od.c: Remove posixver.h and its uses.
(short_options): New constant, which always supports -w[num].
(COMMON_SHORT_OPTIONS): Remove.
* src/pr.c: Remove posixver.h and its uses.
(short_options): New constant, which always supports -S[string].
(COMMON_SHORT_OPTIONS): Remove.
* src/sort.c: Remove posixver.h and its uses.
(short_options): New constant, which always supports -y arg.
(COMMON_SHORT_OPTIONS): Remove.
(main): Redo workaround for Solaris compatibility with -y.
This change isn't visible to the user; it just cleans up the
code so that we don't need posixver.h.
* src/split.c: Remove posixver.h and its uses.
(main): Don't complain about -NUM option.
* src/tail.c (parse_obsolete_option): Don't complain about -NUM.
* src/unexpand.c: Remove posixver.h and its uses.
(main): Don't complain about -TAB.
* src/uniq.c (main): Don't complain about -NUM.

Index: NEWS
===
RCS file: /fetish/cu/NEWS,v
retrieving revision 1.278