summaryrefslogtreecommitdiffstats
path: root/usr.sbin/gstat
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2009-03-12 13:17:46 +0000
committermaxim <maxim@FreeBSD.org>2009-03-12 13:17:46 +0000
commit5b0bfd0e06f9ddd0ca12be3ba6450a2424632d93 (patch)
treeeb89985ca3a033118af64b73c67a3c0013cf2399 /usr.sbin/gstat
parent816892c353334eb943eea4f9b6c04cb63a3dbd8e (diff)
downloadFreeBSD-src-5b0bfd0e06f9ddd0ca12be3ba6450a2424632d93.zip
FreeBSD-src-5b0bfd0e06f9ddd0ca12be3ba6450a2424632d93.tar.gz
o Turn the batch mode on if stdout is not tty.
Submitted by: vsevolod MFC after: 1 week
Diffstat (limited to 'usr.sbin/gstat')
-rw-r--r--usr.sbin/gstat/gstat.86
-rw-r--r--usr.sbin/gstat/gstat.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/gstat/gstat.8 b/usr.sbin/gstat/gstat.8
index fbef6f9..9ac6789 100644
--- a/usr.sbin/gstat/gstat.8
+++ b/usr.sbin/gstat/gstat.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 20, 2006
+.Dd March 12, 2009
.Dt GSTAT 8
.Os
.Sh NAME
@@ -47,7 +47,9 @@ The options are as follows:
.It Fl a
Only display providers that are at least 0.1% busy.
.It Fl b
-Batch mode. Collect numbers, print and exit.
+Batch mode.
+Collect numbers, print and exit.
+Default if stdout is not a tty.
.It Fl c
Enable display of
.Xr geom 4
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index bef33ab..39054eb 100644
--- a/usr.sbin/gstat/gstat.c
+++ b/usr.sbin/gstat/gstat.c
@@ -99,6 +99,10 @@ main(int argc, char **argv)
maxx = -1;
curx = -1;
loop = 1;
+ /* Turn on batch mode if output is not tty. */
+ if (!isatty(fileno(stdout)))
+ flag_b = 1;
+
f_s[0] = '\0';
while ((i = getopt(argc, argv, "adcf:I:b")) != -1) {
switch (i) {
@@ -318,9 +322,11 @@ main(int argc, char **argv)
if (!flag_b)
attron(COLOR_PAIR(i));
PRINTMSG(" %6.1lf", (double)ld[7]);
- if (!flag_b)
+ if (!flag_b) {
attroff(COLOR_PAIR(i));
- PRINTMSG("|");
+ PRINTMSG("|");
+ } else
+ PRINTMSG(" ");
if (gid == NULL) {
PRINTMSG(" ??");
} else if (gid->lg_what == ISPROVIDER) {
OpenPOWER on IntegriCloud