[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regarding head/tail syntax
From: |
Paul Eggert |
Subject: |
Re: regarding head/tail syntax |
Date: |
21 Sep 2003 23:03:51 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Jim covered most of the points nicely, but I thought I'd fill in some
corners:
Aron Griffis <address@hidden> writes:
> I don't see a motivation for their removal, since the older syntax
> is unambiguous and in heavy use by thousands of UNIX scripts already
> in existence.
As Jim said, the motivation is POSIX conformance. I wasn't present
when POSIX was written, but I suspect their motivations were as follows:
(1) Options should use a regular syntax.
(2) Option order should normally not matter.
(You can find more details about this in
<http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap12.html>.)
Clearly, traditional "tail" doesn't obey these rules. For example:
$ tail -1 /etc/motd
Sun Microsystems Inc. SunOS 5.9 Generic May 2002
$ tail -f /etc/motd
Sun Microsystems Inc. SunOS 5.9 Generic May 2002
^C
$ tail -1 -f /etc/motd
tail: cannot open input
$ tail -f -1 /etc/motd
tail: cannot open input
In the process of cleaning up this mess, the POSIX standardizers
decided that "tail -10" should mean the same thing as "tail -1 -0",
i.e. that "1" and "0" should be separate options, just as the
alphabetic options are. This was for regularity. And if option order
doesn't matter, then it should be equivalent to "tail -0 -1", or to
"tail -01". Hence it wasn't right to use that syntax at all, so
people are supposed to use the new "tail -n 10" syntax instead.
Mind you I'm not saying that I would have agreed with all this.
I'm just trying to let you peek into what I suspect was the thought
processors of the POSIX standardizers (who did all this work more than
a decade ago).
> I seriously doubt that any of the commercial UNIXes will ever
> disallow the -number syntax
That's quite possibly true. For example, Solaris (the only commercial
UNIX I regularly use these days) does not conform to POSIX by default.
You have to prepend /usr/xpg4/bin to your path to get a POSIX
environment. I suppose Gentoo could do something like that, but I
don't recommend it; it's a real pain in practice. Better would be
Jim's suggestion to set _POSIX2_VERSION back to _POSIX2_VERSION=199209
somewhere -- either in the default login environment, or in your C
library, or wherever, as a temporary transition aid.
(Whose idea was it to set _POSIX2_VERSION to 200112 in Gentoo's C
library, anyway? :-)
Re: regarding head/tail syntax,
Paul Eggert <=