[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
flex-2.5.31: `head -1' is obsolete, use `sed 1q' or `head -n1' instead
From: |
Jim Meyering |
Subject: |
flex-2.5.31: `head -1' is obsolete, use `sed 1q' or `head -n1' instead |
Date: |
Tue, 12 Aug 2003 06:24:22 +0200 |
Hi,
Thanks for working on flex!
Here's a little patch that you may soon find useful.
But first 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 know 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]
Even if the coreutils programs you use were built on
a system that doesn't claim conformance with that version
of POSIX, you can instruct the affected tools to adhere to
the newer standard by setting _POSIX2_VERSION=200112 in
your environment. That's what I do, and that's how I noticed
the failure reported below.
---------------------------
I'm using `head' from the coreutils-5.0.90 package
and have _POSIX2_VERSION=200112 set in my environment.
When I ran ./configure, I got this:
...
checking if /usr/bin/indent is GNU indent... head: `-1' option is obsolete;
use `-n 1'
Try `head --help' for more information.
no
configure: WARNING: /usr/bin/indent does not appear to be GNU indent.
...
Here is a proposed patch.
If you're concerned about some ancient version of head that doesn't
know about the -n option, you could replace it with `sed 1q'.
2003-08-12 Jim Meyering <address@hidden>
* configure.in: Use `head -n 1' in place of obsolete `head -1'.
--- configure.in.~1~ 2003-08-12 06:08:26.000000000 +0200
+++ configure.in 2003-08-12 06:08:42.000000000 +0200
@@ -48,7 +48,7 @@ AC_PATH_PROG(INDENT, indent, indent)
dnl if INDENT is set to 'indent' then we didn't find indent
if test "$INDENT" != indent ; then
AC_MSG_CHECKING(if $INDENT is GNU indent)
- if $INDENT --version 2>/dev/null | head -1|grep "GNU indent" > /dev/null ;
then
+ if $INDENT --version 2>/dev/null | head -n 1|grep "GNU indent" > /dev/null
; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
- flex-2.5.31: `head -1' is obsolete, use `sed 1q' or `head -n1' instead,
Jim Meyering <=