Merge branch 'awesomeclaw/procps-master'

References:
 procps-ng/procps!62

Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
Craig Small 2020-05-12 19:22:48 +10:00
commit d3e0ff5a0a
3 changed files with 24 additions and 6 deletions

1
NEWS
View File

@ -10,6 +10,7 @@ procps-ng NEXT
* top: ensure config file backward compatibility Debian #951335
* top: add command line 'e' for symmetry with 'E' issue #165
* vmstat: Wide mode gives wider proc columns merge #48
* watch: Add environment variable for interval merge #62
procps-ng-3.3.16
----------------

15
watch.1
View File

@ -1,4 +1,4 @@
.TH WATCH 1 "2018-03-03" "procps-ng" "User Commands"
.TH WATCH 1 "2020-05-12" "procps-ng" "User Commands"
.SH NAME
watch \- execute a program periodically, showing output fullscreen
.SH SYNOPSIS
@ -21,7 +21,8 @@ has changed at least once since first iteration.
\fB\-n\fR, \fB\-\-interval\fR \fIseconds\fR
Specify update interval. The command will not allow quicker than 0.1 second
interval, in which the smaller values are converted. Both '.' and ',' work
for any locales.
for any locales. The WATCH_INTERVAL environment can be used to persistently
set a non-default interval (following the same rules and formatting).
.TP
\fB\-p\fR, \fB\-\-precise\fR
Make
@ -100,6 +101,16 @@ failed, or command exited up on error.
.TP
.B other
The watch will propagate command exit status as child exit status.
.SH ENVIRONMENT
The behaviour of
.B watch
is affected by the following environment variables.
.TP
.B WATCH_INTERVAL
Update interval, follows the same rules as the
.B \-\-interval
command line option.
.SH NOTES
POSIX option processing is used (i.e., option processing stops at
the first non\-option argument). This means that flags after

14
watch.c
View File

@ -668,6 +668,7 @@ int main(int argc, char *argv[])
{
int optc;
double interval = 2;
char *interval_string;
char *command;
char **command_argv;
int command_length = 0; /* not including final \0 */
@ -701,6 +702,10 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
interval_string = getenv("WATCH_INTERVAL");
if(interval_string != NULL)
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))
!= EOF) {
@ -730,10 +735,6 @@ int main(int argc, char *argv[])
break;
case 'n':
interval = strtod_nol_or_err(optarg, _("failed to parse argument"));
if (interval < 0.1)
interval = 0.1;
if (interval > UINT_MAX)
interval = UINT_MAX;
break;
case 'p':
precise_timekeeping = 1;
@ -750,6 +751,11 @@ int main(int argc, char *argv[])
}
}
if (interval < 0.1)
interval = 0.1;
if (interval > UINT_MAX)
interval = UINT_MAX;
if (optind >= argc)
usage(stderr);