TT.file_no was being incorrectly calculated as 0 when tail -f was passed a
single argument, so tail -f with one argument wouldn't actually do the '-f'
part.

Patch attached.
From 3feb4ae50b5135e7c9c8870968f87e318c615ba2 Mon Sep 17 00:00:00 2001
From: Josh Gao <jm...@google.com>
Date: Wed, 16 Mar 2016 15:41:13 -0700
Subject: [PATCH] Fix "tail -f single_file".

TT.file_no was being incorrectly calculated as 0 when tail -f was passed
a single argument.
---
 toys/posix/tail.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index d1c6250..bf25a14 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -136,7 +136,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);
@@ -146,7 +146,7 @@ static void do_tail(int fd, char *name)
   }
 
   if (toys.optc > 1) {
-    if (TT.file_no++) xputc('\n');
+    if (TT.file_no) xputc('\n');
     xprintf("==> %s <==\n", name);
   }
 
-- 
2.7.0.rc3.207.g0ac5344

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to