#include "gbos.h" /* head [-n N] [N]: print the first N lines of stdin (default 10). */ void main(void) { char *argv[8]; unsigned char argc = argv_parse(argv, 8); char *nv = optval(argv, argc, 'n'); unsigned char n = 10, lines = 0; char c; if (nv) n = atou(nv); else if (argc > 0 && argv[0][0] >= '0' && argv[0][0] <= '9') n = atou(argv[0]); for (;;) { c = readc(); if (c == EOF) break; if (lines < n) putc(c); if (c == '\n') lines++; } }