Makes tail -f for multiple files display the header only if another (ie. not
currently displayed) file changed.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
----
-tail
- ./busybox tail -f foo.c~ TODO
- should not print fmt=header_fmt for subsequent date >> TODO; i.e. only
- fmt+ if another (not the current) file did change
Architectural issues:
int *fds;
const char *fmt;
+ int prev_fd;
INIT_G();
xwrite(STDOUT_FILENO, tailbuf, taillen);
}
} while (++i < nfiles);
+ prev_fd = fds[i-1];
tailbuf = xrealloc(tailbuf, BUFSIZ);
nread = tail_read(fd, tailbuf, BUFSIZ);
if (nread <= 0)
break;
- if (fmt) {
+ if (fmt && (fd != prev_fd)) {
tail_xprint_header(fmt, filename);
fmt = NULL;
+ prev_fd = fd;
}
xwrite(STDOUT_FILENO, tailbuf, nread);
}