summaryrefslogtreecommitdiffstats
path: root/usr.bin/head
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-08-15 19:34:11 +0000
committerjoerg <joerg@FreeBSD.org>1995-08-15 19:34:11 +0000
commit71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090 (patch)
tree8c8815f3ef8d028770e6485888351389c6c66bbe /usr.bin/head
parent93d48be4a6907a0ccebf53f88e5753edf82ebe34 (diff)
downloadFreeBSD-src-71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090.zip
FreeBSD-src-71bcd71cfdc03a7a9dce2cae6ab4d8bc9f087090.tar.gz
head(1) ignored EOFs (in certain cases).
Closes PR # bin/678: head(1) ignore EOF Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider)
Diffstat (limited to 'usr.bin/head')
-rw-r--r--usr.bin/head/head.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c
index e33a3c2..3c4865b 100644
--- a/usr.bin/head/head.c
+++ b/usr.bin/head/head.c
@@ -113,12 +113,11 @@ head(fp, cnt)
{
register int ch;
- while (cnt--)
- while ((ch = getc(fp)) != EOF) {
+ while ((ch = getc(fp)) != EOF && cnt) {
if (putchar(ch) == EOF)
err(1, "stdout: %s", strerror(errno));
if (ch == '\n')
- break;
+ cnt--;
}
}
OpenPOWER on IntegriCloud