bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF


From: Bob Proulx
Subject: bug#8102: [head] do not return EXIT_SUCCESS upon premature EOF
Date: Fri, 25 Feb 2011 15:23:32 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

tags 8102 + notabug
thanks

Bjartur Thorlacius wrote:
> Indeed. Since it's explicitly mentioned, I assume there's a reason for
> it. I'd be grateful if someone could point out what the rationale beind
> the decision is (or better yet, where such information can be found).

Mostly because that is how the tool has always behaved since the first
implementation of the program.  Because BSD, System V, GNU (and HP-UX,
IBM AIX, SunOS/Solaris, many others) all implemented it the same way
it was standardized that way for POSIX so that future implementations
would be the same and not break backward compatibility with the
previously existing implementations.  After something has been that
way for twenty plus years there often isn't a particular reason other
than if you change it then you break twenty years worth of scripting
that expects it.  For many of these the tool came first and then
people documented the existing behavior.

The equivalent to head has always been sed.  All of these print the
first five lines of a file:

  head -n5
  sed -n 1,5p
  sed 5q

None of those require five lines or exit with an error code.
Personally I have never thought about that possibility nor needed it.

> So should I be using a head-alike for iterating over lines, and
> would such an utility belong to a GNU package, or is awk the right
> tool for the job?

What are you trying to do?

Bob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]