rebased:

Exit immediately if we don't actually have anything to -f --- it's -f's
big brother -F that retries by name rather than by fd.
---
 toys/posix/tail.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index a00bfa0..d1c6250 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -245,7 +245,7 @@ void tail_main(void)
   loopfiles_rw(args, O_RDONLY|(O_CLOEXEC*!(toys.optflags&FLAG_f)),
     0, 0, do_tail);

-  if (toys.optflags & FLAG_f) {
+  if ((toys.optflags & FLAG_f) && TT.file_no) {
     int len, last_fd = TT.files[(TT.file_no-1)*2], i, fd;
     struct inotify_event ev;

-- 
2.6.0.rc2.230.g3dd15c0

On Mon, Dec 21, 2015 at 1:24 PM, enh <[email protected]> wrote:
> Check for fatal errors, and exit immediately if we don't actually have
> anything to -f --- something like "tail -f /does/not/exist" should exit:
> it's -f's big brother -F that retries by name rather than by fd.
> ---
>  toys/posix/tail.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
>
> --
> Elliott Hughes - http://who/enh - http://jessies.org/~enh/
> Android native code/tools questions? Mail me/drop by/add me as a reviewer.



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 40b0d672f5870a11e57339c10199265e78dc6c9f Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Sat, 9 Jan 2016 12:54:04 -0800
Subject: [PATCH] Fix tail -f /does/not/exist.

Exit immediately if we don't actually have anything to -f --- it's -f's
big brother -F that retries by name rather than by fd.
---
 toys/posix/tail.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index a00bfa0..d1c6250 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -245,7 +245,7 @@ void tail_main(void)
   loopfiles_rw(args, O_RDONLY|(O_CLOEXEC*!(toys.optflags&FLAG_f)),
     0, 0, do_tail);
 
-  if (toys.optflags & FLAG_f) {
+  if ((toys.optflags & FLAG_f) && TT.file_no) {
     int len, last_fd = TT.files[(TT.file_no-1)*2], i, fd;
     struct inotify_event ev;
 
-- 
2.6.0.rc2.230.g3dd15c0

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to