Date: Sun, 13 Aug 1995 00:46:18 +0200 From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/678: head(1) ignore EOF Message-ID: <199508122246.AAA01206@localhost> Resent-Message-ID: <199508122300.QAA25327@freefall.FreeBSD.org>
next in thread | raw e-mail | index | archive | help
>Number: 678 >Category: bin >Synopsis: head(1) ignore EOF >Confidential: yes >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 12 16:00:01 PDT 1995 >Last-Modified: >Originator: Wolfram Schneider >Organization: >Release: FreeBSD 2.0-ALPHA i386 >Environment: >Description: head(1) ignore EOF >How-To-Repeat: $ echo "one line" > /tmp/foo $ head -100000000000 /tmp/foo ^C >Fix: --- 1.1 1995/08/12 22:14:38 +++ head.c 1995/08/12 22:18:58 @@ -113,12 +113,11 @@ { 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--; } } >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508122246.AAA01206>