aboutsummaryrefslogtreecommitdiff
path: root/toys/head.c
diff options
context:
space:
mode:
authorTimothy Elliott <tle@holymonkey.com>2012-02-10 21:59:57 -0800
committerTimothy Elliott <tle@holymonkey.com>2012-02-10 21:59:57 -0800
commit270366f582fdf4fc704c4896b15efa0e84eb77a0 (patch)
tree3e2273054888ecbbd2a24a9001408e1b072a1716 /toys/head.c
parent365bda87f40d0a2d410ebfe025d43ee13444058f (diff)
downloadtoybox-270366f582fdf4fc704c4896b15efa0e84eb77a0.tar.gz
Add tests for head
This exposed one issue in head.c -- printf was not flushing and file names could appear after file contents instead of before. The issue is fixed by calling xflush after xprintf.
Diffstat (limited to 'toys/head.c')
-rw-r--r--toys/head.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/head.c b/toys/head.c
index 87fbe62a..1d1e54a3 100644
--- a/toys/head.c
+++ b/toys/head.c
@@ -35,8 +35,9 @@ static void do_head(int fd, char *name)
if (toys.optc > 1) {
// Print an extra newline for all but the first file
- if (TT.file_no++) printf("\n");
+ if (TT.file_no++) xprintf("\n");
xprintf("==> %s <==\n", name);
+ xflush();
}
while (lines) {