diff options
Diffstat (limited to 'c/head.c')
| -rw-r--r-- | c/head.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -16,10 +16,10 @@ void main(void) { } if (fname) { fd = open(fname, O_READ); - if (fd == NOFD) { puts("head: no such file"); nl(); return; } + if (fd > 3) { puts("head: no such file"); nl(); return; } } for (;;) { - if (fd == NOFD) { char c = readc(); if (c == EOF) break; ch = c; } + if (fd > 3) { char c = readc(); if (c == EOF) break; ch = c; } else { ch = fgetc(fd); if (ch < 0) break; } if (lines < n) putc((char)ch); if (ch == '\n') lines++; |
