My previous changes to tail were too drastic: they removed support
for some traditional usage that is not in POSIX 1003.2-1992 but is in
SUSv2 or in older GNU tail. I installed the following patch as
penance. It makes tail a bit more generous about what it supports,
though tail -10 still is rejected when in POSIX 1003.1-2001 mode
pending resolution of this issue at the Open Group level.
2004-09-23 Paul Eggert [EMAIL PROTECTED]
* doc/coreutils.texi (tail invocation): Fix bugs in the description of
the obsolete syntax (e.g., it does not support -k or -m). Warn
about usages like tail - and tail -c 4 that are ambigous on
older systems.
* src/tail.c (parse_obsolete_option): Bring back support
for obsolete option followed by non-obsolete, or by more
than one file. When obsolete, conform to SUSv2 rather than
original POSIX 1003.2-1992, as SUSv2 corrected the case of
tail -c. Add support for the SUSv2 b modifier.
* NEWS: Mention the above.
* tests/tail/Test.pm: New test case obs-b to check the above.
err-[134] no longer need _POSIX2_VERSION=199209.
Fix comments to match revised behavior.
Index: NEWS
===
RCS file: /fetish/cu/NEWS,v
retrieving revision 1.236
diff -p -u -r1.236 NEWS
--- NEWS21 Sep 2004 22:00:27 - 1.236
+++ NEWS23 Sep 2004 20:23:49 -
@@ -101,10 +101,11 @@ GNU coreutils NEWS
tail -f no longer mishandles pipes and fifos. With no operands,
tail now ignores -f if standard input is a pipe, as POSIX requires.
- When conforming to POSIX 1003.2-1992, tail now handles some obscure
- cases more correctly, e.g., tail +cl file now reads the file +cl
- rather than reporting an error, and tail - file no longer reads
- standard input.
+ When conforming to POSIX 1003.2-1992, tail now supports the SUSv2 b
+ modifier (e.g., tail -10b file) and it handles some obscure cases
+ more correctly, e.g., tail +cl now reads the file +cl rather
+ than reporting an error, tail -c file no longer reports an error,
+ and tail - file no longer reads standard input.
tee now exits when it gets a SIGPIPE signal, as POSIX requires.
To get tee's old behavior, use the shell command (trap '' PIPE; tee).
Index: doc/coreutils.texi
===
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.213
diff -p -u -r1.213 coreutils.texi
--- doc/coreutils.texi 21 Sep 2004 05:56:11 - 1.213
+++ doc/coreutils.texi 23 Sep 2004 20:23:53 -
@@ -2552,15 +2552,20 @@ Always print file name headers.
@end table
On older systems, @command{tail} supports an obsolete option
[EMAIL PROTECTED]@[EMAIL PROTECTED], which is recognized only if it is
-specified first. @var{count} is a decimal number optionally followed
-by a size letter (@samp{b}, @samp{k}, @samp{m}) as in @option{-c}, or
[EMAIL PROTECTED] to mean count by lines, or other option letters
-(@samp{cfqv}). Some older @command{tail} implementations also support
-an obsolete option @[EMAIL PROTECTED] with the same meaning as
[EMAIL PROTECTED]@var{count}}. @acronym{POSIX} 1003.1-2001 (@pxref{Standards
-conformance}) does not allow these options; use @option{-c
[EMAIL PROTECTED] or @option{-n @var{count}} instead.
[EMAIL PROTECTED]@var{count}[bcl][f]}, which is recognized only if it is
+specified first. @var{count} is an optional decimal number optionally
+followed by a size letter (@samp{b}, @samp{c}, @samp{l}) to mean count
+by 512-byte blocks, bytes, or lines, optionally followed by @samp{f}
+which has the same meaning as @option{-f}. Also, the leading @samp{-}
+can be replaced by @samp{+} with the same meaning as in counts.
[EMAIL PROTECTED] 1003.1-2001 (@pxref{Standards conformance}) does not
+allow most of these obsolete usages; use @option{-c @var{count}[b]},
[EMAIL PROTECTED] @var{count}}, and/or @option{-f} instead.
+
+On older systems, obsolete usage overrides normal usage, so portable
+shell scripts should avoid commands that can be interpreted either
+way. For example, use @samp{tail -- - file} rather than @samp{tail -
+file}, and use @samp{tail -c4} rather than @samp{tail -c 4}.
@exitstatus
Index: src/tail.c
===
RCS file: /fetish/cu/src/tail.c,v
retrieving revision 1.228
diff -p -u -r1.228 tail.c
--- src/tail.c 21 Sep 2004 22:26:42 - 1.228
+++ src/tail.c 23 Sep 2004 20:23:54 -
@@ -1375,14 +1375,15 @@ parse_obsolete_option (int argc, char *
const char *n_string;
const char *n_string_end;
bool obsolete_usage;
+ int default_count = DEFAULT_N_LINES;
bool t_from_start;
bool t_count_lines = true;
bool t_forever = false;
- int len;
/* With the obsolete form, there is one option string and
- at most one file argument, possibly preceded by --. */
- if