Old head syntax still present in cvs?

i thought i e-mailed the list about this a while back but with the release of
1.2.7 i found that the old syntax is still present in configure.in:
root at vapier 0 SDL-1.2.7 # grep ‘head -1’ *
configure.in: esd_lib=ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'
configure.in: arts_lib=ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'

on machines running the latest coreutils from GNU, this results in an
error … head -# and tail -# syntax has been removed per the latest
POSIX specs and coreutils has been updated accordingly …
the ‘proper’ way (according to POSIX) is head -n # and tail -n #
the only other way would be to export POSIX environment variables so that the
binaries will accept the old style syntax … a pita :wink:
-mike

Mike Frysinger wrote:

i thought i e-mailed the list about this a while back but with the release of
1.2.7 i found that the old syntax is still present in configure.in:
root at vapier 0 SDL-1.2.7 # grep ‘head -1’ *
configure.in: esd_lib=ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'
configure.in: arts_lib=ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'

on machines running the latest coreutils from GNU, this results in an
error … head -# and tail -# syntax has been removed per the latest
POSIX specs and coreutils has been updated accordingly …
the ‘proper’ way (according to POSIX) is head -n # and tail -n #
the only other way would be to export POSIX environment variables so that the
binaries will accept the old style syntax … a pita :wink:
-mike

sed #q == head -# … in this case, sed 1q == head -1, and portable

cheers,
– guido http://AC-Archive.sf.net

i’m not 100% sure what you’re getting at here but if you’re saying this code
is portable, i’d point out that it isnt portable on linux systems that use
the latest coreutils w/out extra work on the part of the end user
-mikeOn Tuesday 02 March 2004 04:40 pm, Guido Draheim wrote:

sed #q == head -# … in this case, sed 1q == head -1, and
portable

Either works on Debian unstable.

Anyway, Autoconf is there for portability, so whichever code is more
portable on more systems should be used. For now, the -1 syntax should be
more portable, on systems with older “head” program, and the new "head"
program (at least from Gnu) seems to accept either, so configure.in should
use -1.

In the future, if the head program that accepts only POSIX-style input
syntax appears, configure.in should run a test to see which syntax is used
on the system, then use that syntax. Lol… that’s sort of funny… isn’t
POSIX supposed to make it easier to port programs, not harder? =P

-MarkOn Tue, 2 Mar 2004, Mike Frysinger wrote:

On Tuesday 02 March 2004 04:40 pm, Guido Draheim wrote:

sed #q == head -# … in this case, sed 1q == head -1, and
portable

i’m not 100% sure what you’re getting at here but if you’re saying this code
is portable, i’d point out that it isnt portable on linux systems that use
the latest coreutils w/out extra work on the part of the end user
-mike


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage

Sed is not part of coreutils, and I’m pretty sure the syntax Guido
recommends is portable.

At 3/2/2004, Mike Frysinger wrote:>On Tuesday 02 March 2004 04:40 pm, Guido Draheim wrote:

sed #q == head -# … in this case, sed 1q == head -1, and
portable

i’m not 100% sure what you’re getting at here but if you’re saying this code
is portable, i’d point out that it isnt portable on linux systems that use
the latest coreutils w/out extra work on the part of the end user

very true … i read that as seq, not sed, my mistake
-mikeOn Tuesday 02 March 2004 05:31 pm, Jon Willeke wrote:

Sed is not part of coreutils, and I’m pretty sure the syntax Guido
recommends is portable.

Either works on Debian unstable.

if you’re using coreutils-5.0.91 and it works it’s probably because debian has
patched it to work (mandrake and fedora have afaik)

In the future, if the head program that accepts only POSIX-style input
syntax appears, configure.in should run a test to see which syntax is used
on the system, then use that syntax. Lol… that’s sort of funny… isn’t
POSIX supposed to make it easier to port programs, not harder? =P

it has changed which is why i sent this e-mail :wink:
diff in question:
http://savannah.gnu.org/cgi-bin/viewcvs/coreutils/coreutils/src/head.c.diff?r1=1.68&r2=1.69

example:
$ cat << EOF > somefile

line1
line2
line3
EOF
$ head -1 somefile
head: -1' option is obsolete; use-n 1’
Try `head --help’ for more information.
$ head -n 1 somefile
line1
-mikeOn Tuesday 02 March 2004 05:08 pm, Mark K. Kim wrote:

Following up on Guido’s suggestion, the two commands

head -1 | sed ‘s/./(.)/\1/’

can be simplified to one

sed ‘s/./(.)/\1/; q’

I’m pretty sure that’s portable, too.

At 06:15 PM 3/2/2004 -0500, Mike Frysinger wrote:>On Tuesday 02 March 2004 05:31 pm, Jon Willeke wrote:

Sed is not part of coreutils, and I’m pretty sure the syntax Guido
recommends is portable.

very true … i read that as seq, not sed, my mistake

Following up on Guido’s suggestion, the two commands

head -1 | sed ‘s/./(.)/\1/’

can be simplified to one

sed ‘s/./(.)/\1/; q’

I’m pretty sure that’s portable, too.

Thanks. :slight_smile:

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment