GNU bug report logs -
#8102
[head] do not return EXIT_SUCCESS upon premature EOF
Previous Next
Full log
Message #14 received at 8102 <at> debbugs.gnu.org (full text, mbox):
Bjartur Thorlacius writes:
>
> On 2/23/11, Eric Blake <eblake <at> redhat.com> wrote:
> > On 02/23/2011 11:58 AM, Bjartur Thorlacius wrote:
> > That's because this is not a bug, but a POSIX requirement:
> >
> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html
> >
> > "When a file contains less than number lines, it shall be copied to
> > standard output in its entirety. This shall not be an error."
> >
> 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).
>
> 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?
Here's what an iterate-over-lines loop normally looks like in a shell script:
while read -r line
do
something $line
done
The idea of using head to control a loop means you are either a newbie who
didn't know about "read", or you are trying to do something subtly different
which I didn't understand. Excuse me if I guessed the wrong one.
--
Alan Curry
This bug report was last modified 13 years and 209 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.