aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-03-18 14:12:53 -0500
committerRob Landley <rob@landley.net>2016-03-18 14:12:53 -0500
commitada3c0876dc99b6b1ef457e06d271d3b933f9dd9 (patch)
treecad62be15bf0b6b33ec8cd16823515a80cc9b3c1 /toys
parent426bc7fb4fcdd7e28544f8fb29854316a1784850 (diff)
downloadtoybox-ada3c0876dc99b6b1ef457e06d271d3b933f9dd9.tar.gz
Fix last commit (had newline before first ==> name <==) and add -f tests.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/tail.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index bf25a149..1204f1c6 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -3,6 +3,8 @@
* Copyright 2012 Timothy Elliott <tle@holymonkey.com>
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/tail.html
+ *
+ * Deviations from posix: -f waits for pipe/fifo on stdin (nonblock?).
USE_TAIL(NEWTOY(tail, "?fc-n-[-cn]", TOYFLAG_USR|TOYFLAG_BIN))
@@ -136,7 +138,7 @@ static void do_tail(int fd, char *name)
int linepop = 1;
if (toys.optflags & FLAG_f) {
- int f = (TT.file_no++)*2;
+ int f = TT.file_no*2;
char *s = name;
if (!fd) sprintf(s = toybuf, "/proc/self/fd/%d", fd);
@@ -145,10 +147,8 @@ static void do_tail(int fd, char *name)
perror_msg("bad -f on '%s'", name);
}
- if (toys.optc > 1) {
- if (TT.file_no) xputc('\n');
- xprintf("==> %s <==\n", name);
- }
+ if (TT.file_no++) xputc('\n');
+ if (toys.optc > 1) xprintf("==> %s <==\n", name);
// Are we measuring from the end of the file?