[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regarding head/tail syntax
From: |
Jim Meyering |
Subject: |
Re: regarding head/tail syntax |
Date: |
Sun, 21 Sep 2003 15:21:05 +0200 |
Aron Griffis <address@hidden> wrote:
...
> Additionally, I noted that the Single UNIX Specification does not make
> application recommendations for tail, although it refers to the older
> syntax as obsolescent.
SUSv2 is pretty old.
POSIX 1003.1-2001 is more relevant these days.
Usage like `tail -1', `head +2', `sort +1' has been classified as
obsolescent for many years. Recently, it has finally become
officially `obsolete'.
A little background:
A long time ago, POSIX decided that certain types of
options (like `-1' +6, etc.) should eventually be considered invalid.
That's why people have been moving away from uses of e.g., `sort +N' to
`sort -kM,M'. Less well known is the fact that commands like these
head -1
tail +2
tail -4
uniq -3
(and more)
are all technically obsolete, now.
And if you build the GNU coreutils on a system that conforms to
POSIX 1003.1-2001, then you'll find that the above all fail, e.g. like this:
$ head -1
head: `-1' option is obsolete; use `-n 1'
Try `head --help' for more information.
[Exit 1]
>From the coreutils documentation:
For example, if you are running older software that
assumes an older version of POSIX and uses `sort +1', `head -1', or
`tail +1', you can work around the compatibility problems by setting
`_POSIX2_VERSION=199209' in your environment.
> The pain I'm seeing in the Gentoo Linux distribution, along with the
> above research, leads me to question the rationale behind removing the
> -number syntax in the GNU coreutils. Personally, 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. It
Short answer: it's required for conformance to POSIX 1003.1-2001.
See the `Standards Conformance' section in the coreutils documentation.
E.g., run `info coreutils standards'.
Since you're encountering this problem, it's almost certainly the result
of your building coreutils with a C library and headers that indicate the
system conforms to POSIX 1003.1-2001 by virtue of the definition of
_POSIX2_VERSION in <unistd.h>.
> doesn't seem fruitful for the Gentoo developers (along with developers
> of other distributions) to spend our time making this trivial change in
> hundreds of packages, and trying to push the changes upstream.
You may find solace in the fact that you're not alone :-)
All distributions that care about standards conformance are (or will be)
facing the same battle. Some began making such changes a few months ago,
so you may have less work than you think.
> Would the coreutils maintainers consider reinstating the older syntax to
> save us the unnecessary toil? If that is not considered an option,
> would you mind explaining the rationale behind making this change to the
> head/tail programs? I checked the coreutils FAQ but didn't find
> coverage of this topic.
I suggest you do something like what Debian has done:
Give yourselves a little breathing room by making it so coreutils'
lib/posixver.c is compiled with _POSIX2_VERSION #defined to a value
so that it doesn't cause all that trouble just yet.
Then, try to convince gentoo/upstream developers to set
_POSIX2_VERSION=200112 in their environment and to fix any
problems that are exposed.
Re: regarding head/tail syntax, Paul Eggert, 2003/09/22