* Copyright (c) 1995 Martin Schulze <joey@infodrom.north.de>
* Ammended by cblake to only export the function symbol.
*
- * Modified by Albert Cahalan
+ * Modified by Albert Cahalan, ????-2003
*
* Redistributable under the terms of the
* GNU Library General Public License; see COPYING
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
-int linux_version_code = 0;
+int linux_version_code;
static void init_Linux_version(void) __attribute__((constructor));
static void init_Linux_version(void) {
static struct utsname uts;
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
- if (linux_version_code) return;
if (uname(&uts) == -1) /* failure implies impending death */
exit(1);
if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
watch \- execute a program periodically, showing output fullscreen
.SH SYNOPSIS
.B watch
-.I [\-dhv] [\-n <seconds>] [\-\-differences[=cumulative]] [\-\-help] [\-\-interval=<seconds>] [\-\-version] <command>
+.I [\-dhvt] [\-n <seconds>] [\-\-differences[=cumulative]] [\-\-help] [\-\-interval=<seconds>] [\-\-no\-title] [\-\-version] <command>
.SH DESCRIPTION
.BR watch
runs
flag will highlight the differences between successive updates. The
.I --cumulative
option makes highlighting "sticky", presenting a running display of all
-positions that have ever changed.
+positions that have ever changed. The
+.I -t
+or
+.I --no-title
+option turns off the header showing the interval, command, and current
+time at the top of the display, as well as the following blank line.
.PP
.BR watch
will run until interrupted.
{"differences", optional_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"interval", required_argument, 0, 'n'},
+ {"no-title", no_argument, 0, 't'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
static char usage[] =
- "Usage: %s [-dhnv] [--differences[=cumulative]] [--help] [--interval=<n>] [--version] <command>\n";
+ "Usage: %s [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] [--no-title] [--version] <command>\n";
static char *progname;
static int height = 24, width = 80;
static int screen_size_changed = 0;
static int first_screen = 1;
+static int show_title = 2; // number of lines used, 2 or 0
#define min(x,y) ((x) > (y) ? (y) : (x))
setlocale(LC_ALL, "");
progname = argv[0];
- while ((optc = getopt_long(argc, argv, "+d::hn:v", longopts, (int *) 0))
+ while ((optc = getopt_long(argc, argv, "+d::hn:vt", longopts, (int *) 0))
!= EOF) {
switch (optc) {
case 'd':
case 'h':
option_help = 1;
break;
+ case 't':
+ show_title = 0;
+ break;
case 'n':
{
char *str;
first_screen = 1;
}
- /* left justify interval and command, right justify time, clipping all
- to fit window width */
- asprintf(&header, "Every %ds: %.*s",
- interval, min(width - 1, command_length), command);
- mvaddstr(0, 0, header);
- if (strlen(header) > (size_t) (width - tsl - 1))
- mvaddstr(0, width - tsl - 4, "... ");
- mvaddstr(0, width - tsl + 1, ts);
- free(header);
+ if (show_title) {
+ // left justify interval and command,
+ // right justify time, clipping all to fit window width
+ asprintf(&header, "Every %ds: %.*s",
+ interval, min(width - 1, command_length), command);
+ mvaddstr(0, 0, header);
+ if (strlen(header) > (size_t) (width - tsl - 1))
+ mvaddstr(0, width - tsl - 4, "... ");
+ mvaddstr(0, width - tsl + 1, ts);
+ free(header);
+ }
if (!(p = popen(command, "r"))) {
perror("popen");
do_exit(2);
}
- for (y = 2; y < height; y++) {
+ for (y = show_title; y < height; y++) {
int eolseen = 0, tabpending = 0;
for (x = 0; x < width; x++) {
int c = ' ';