-.TH WATCH 1 "2020-06-04" "procps-ng" "User Commands"
+.TH WATCH 1 "2020-10-19" "procps-ng" "User Commands"
.SH NAME
watch \- execute a program periodically, showing output fullscreen
.SH SYNOPSIS
.B sh \-c
which reduces the need to use extra quoting to get the desired effect.
.TP
+\fB\-w\fR, \fB\-\-no\-linewrap\fR
+Turn off line wrapping. Long lines will be truncated instead of wrapped to the next line.
+.TP
\fB\-h\fR, \fB\-\-help\fR
Display help text and exit.
.TP
static int first_screen = 1;
static int show_title = 2; /* number of lines used, 2 or 0 */
static int precise_timekeeping = 0;
+static int line_wrap = 1;
#define min(x,y) ((x) > (y) ? (y) : (x))
#define MAX_ANSIBUF 100
fputs(_(" -n, --interval <secs> seconds to wait between updates\n"), out);
fputs(_(" -p, --precise attempt run command in precise intervals\n"), out);
fputs(_(" -t, --no-title turn off header\n"), out);
+ fputs(_(" -w, --no-wrap turn off line wrapping\n"), out);
fputs(_(" -x, --exec pass command to exec instead of \"sh -c\"\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
return;
}
+static void find_eol(FILE *p)
+{
+ int c;
+#ifdef WITH_WATCH8BIT
+ do {
+ c = my_getwc(p);
+ } while (c != WEOF
+ && c!= L'\n');
+#else
+ do {
+ c = getc(p);
+ } while (c != EOF
+ && c != '\n');
+#endif /* WITH_WATCH8BIT */
+}
+
static int run_command(char *restrict command, char **restrict command_argv)
{
FILE *p;
#endif
}
oldeolseen = eolseen;
+ if (!line_wrap) {
+ reset_ansi();
+ if (flags & WATCH_COLOR)
+ attrset(A_NORMAL);
+ find_eol(p);
+ }
}
fclose(p);
{"exec", no_argument, 0, 'x'},
{"precise", no_argument, 0, 'p'},
{"no-title", no_argument, 0, 't'},
+ {"no-wrap", no_argument, 0, 'w'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
interval = strtod_nol_or_err(interval_string, _("Could not parse interval from WATCH_INTERVAL"));
while ((optc =
- getopt_long(argc, argv, "+bced::ghn:pvtx", longopts, (int *)0))
+ getopt_long(argc, argv, "+bced::ghn:pvtwx", longopts, (int *)0))
!= EOF) {
switch (optc) {
case 'b':
case 't':
show_title = 0;
break;
+ case 'w':
+ line_wrap = 0;
+ break;
case 'x':
flags |= WATCH_EXEC;
break;