OSDN Git Service

Fix tail -f /does/not/exist.
authorElliott Hughes <enh@google.com>
Sat, 9 Jan 2016 20:54:04 +0000 (12:54 -0800)
committerRob Landley <rob@landley.net>
Mon, 11 Jan 2016 05:01:28 +0000 (23:01 -0600)
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

index a00bfa0..d1c6250 100644 (file)
@@ -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;