diff options
author | Rob Landley <rob@landley.net> | 2024-04-05 12:41:16 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2024-04-05 12:41:16 -0500 |
commit | 9303bd8ae667ef6385f070aa4937ff8746a2ff59 (patch) | |
tree | cb23dc31f1263858d07898330eacebb440912f6a | |
parent | fc0e86b438e813eca267c5a0fd60a4be0792f6bc (diff) | |
download | toybox-9303bd8ae667ef6385f070aa4937ff8746a2ff59.tar.gz |
Tweak help text and comments.
-rw-r--r-- | toys/other/watch.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/toys/other/watch.c b/toys/other/watch.c index fbd95455..a47aa3c2 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -1,4 +1,4 @@ -/* watch.c - Execute a program periodically +/* watch.c - Show bounded output of a periodically executed command. * * Copyright 2013 Sandeep Sharma <sandeep.jack2756@gmail.com> * Copyright 2013 Kyungwan Han <asura321@gmail.com> @@ -6,21 +6,22 @@ * No standard. See http://man7.org/linux/man-pages/man1/watch.1.html * * TODO: trailing combining characters + USE_WATCH(NEWTOY(watch, "^<1n%<100=2000tebx", TOYFLAG_USR|TOYFLAG_BIN)) config WATCH bool "watch" default y help - usage: watch [-tebx] [-n SEC] PROG ARGS + usage: watch [-tebx] [-n SEC] COMMAND... - Run PROG every -n seconds, showing output. Hit q to quit. + Run COMMAND every -n seconds, showing output that fits terminal, q to quit. - -n Loop period in seconds (default 2) + -n Number of seconds between repeats (default 2.0) -t Don't print header -e Exit on error -b Beep on command error - -x Exec command directly (vs "sh -c") + -x Exec command directly (without "sh -c") */ #define FOR_watch @@ -57,7 +58,7 @@ static void watch_child(int sig) static int watch_escape(FILE *out, int cols, int wc) { if (wc==27 || (wc>=7 && wc<=13)) return -1; - if (wc < 32) return 0; + if (wc<32) return 0; return crunch_escape(out, cols, wc); } @@ -88,13 +89,12 @@ void watch_main(void) xsignal_flags(SIGCHLD, watch_child, SA_RESTART|SA_NOCLDSTOP); for (;;) { - fflush(NULL); + fflush(0); // Time for a new period? if ((now = millitime())>=then) { - // Incrementing then instead of adding offset to now avoids drift, - // loop is in case we got suspend/resumed and need to skip periods + // loop in case we got suspend/resumed and need to skip periods while ((then += TT.n)<=now); start_redraw(&width, &height); |