On Sat, 19 Mar 2011, Justin Krejci wrote:

> On Fri, 18 Mar 2011, Mike Miller wrote:
>
>> I thought it made sense for GNU to maintain the +n option, but a file 
>> could be named "+2" so the command becomes ambiguous if a file by that 
>> name exists.
>
> Don't most (gnu) commands support the -- notation to signify end of the 
> options and anything after is a file argument, stdin, or whatever?

Yes.  The idea of -- is that a filename beginning with - will be treated 
as an option unless you precede it with --.  I assume that was how they 
used to deal with files named +2, or similar.  (See below -- it is true.)

>From the info page:

    On older systems, the leading `-' can be replaced by `+' in the
obsolete option syntax with the same meaning as in counts, and obsolete
usage overrides normal usage when the two conflict.  This obsolete
behavior can be enabled or disabled with the `_POSIX2_VERSION'
environment variable (*note Standards conformance::).

    Scripts intended for use on standard hosts should avoid obsolete
syntax and should use `-c COUNT[b]', `-n COUNT', and/or `-f' instead.
If your script must also run on hosts that support only the obsolete
syntax, you can often rewrite it to avoid problematic usages, e.g., by
using `sed -n '$p'' rather than `tail -1'.  If that's not possible, the
script can use a test like `if tail -c +1 </dev/null >/dev/null 2>&1;
then ...' to decide which syntax to use.

    Even if your script assumes the standard behavior, you should still
beware usages whose behaviors differ depending on the POSIX version.
For example, avoid `tail - main.c', since it might be interpreted as
either `tail main.c' or as `tail -- - main.c'; avoid `tail -c 4', since
it might mean either `tail -c4' or `tail -c 10 4'; and avoid `tail +4',
since it might mean either `tail ./+4' or `tail -n +4'.

According to this...

http://www.gnu.org/software/coreutils/manual/html_node/Standards-conformance.html#Standards-conformance

...if you want the old behavior, you can set this:

_POSIX2_VERSION=199209

I tried it and it worked:

$ export _POSIX2_VERSION=199209

$ echo -e "a\nb\nc\nd" | tail +2
b
c
d

$ echo -e "a\nb\nc\nd" > +2

$ tail +2 +2
b
c
d

$ tail +2
[hangs]

$ tail -- +2
a
b
c
d

Yep, the -- trick does it.

Mike