diff options
author | Rob Landley <rob@landley.net> | 2021-07-04 11:57:40 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-07-04 11:57:40 -0500 |
commit | ba242e08ee83910596420f42830fd3d6fc1868d0 (patch) | |
tree | b9b45e99216ea7a716be25a15f3405e5a82b9008 /lib/lib.c | |
parent | 933f238bd1dfd8931fa3cc60f61aea19802daefd (diff) | |
download | toybox-ba242e08ee83910596420f42830fd3d6fc1868d0.tar.gz |
Teach tail -F to work on file that doesn't initially exist (needed
new lib/ flag), allow -s to be fraction of a second, inline (anonymous)
struct so globals.h isn't using an incomplete type, blank line in
GLOBALS() between option args and other variables, collate
tail_continue() to one function, add test.
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -713,9 +713,9 @@ void poke(void *ptr, long long val, unsigned size) void loopfiles_rw(char **argv, int flags, int permissions, void (*function)(int fd, char *name)) { - int fd, failok = !(flags&WARN_ONLY); + int fd, failok = !(flags&WARN_ONLY), anyway = flags & LOOPFILES_ANYWAY; - flags &= ~WARN_ONLY; + flags &= ~(WARN_ONLY|LOOPFILES_ANYWAY); // If no arguments, read from stdin. if (!*argv) function((flags & O_ACCMODE) != O_RDONLY ? 1 : 0, "-"); @@ -726,10 +726,10 @@ void loopfiles_rw(char **argv, int flags, int permissions, if (!strcmp(*argv, "-")) fd = 0; else if (0>(fd = notstdio(open(*argv, flags, permissions))) && !failok) { perror_msg_raw(*argv); - continue; + if (!anyway) continue; } function(fd, *argv); - if ((flags & O_CLOEXEC) && fd) close(fd); + if ((flags & O_CLOEXEC) && fd>0) close(fd); } while (*++argv); } |