From owner-svn-src-head@FreeBSD.ORG Thu Mar 12 13:17:46 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E260106564A; Thu, 12 Mar 2009 13:17:46 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C7BF8FC12; Thu, 12 Mar 2009 13:17:46 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2CDHktP031336; Thu, 12 Mar 2009 13:17:46 GMT (envelope-from maxim@svn.freebsd.org) Received: (from maxim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2CDHk22031334; Thu, 12 Mar 2009 13:17:46 GMT (envelope-from maxim@svn.freebsd.org) Message-Id: <200903121317.n2CDHk22031334@svn.freebsd.org> From: Maxim Konovalov Date: Thu, 12 Mar 2009 13:17:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189739 - head/usr.sbin/gstat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2009 13:17:47 -0000 Author: maxim Date: Thu Mar 12 13:17:46 2009 New Revision: 189739 URL: http://svn.freebsd.org/changeset/base/189739 Log: o Turn the batch mode on if stdout is not tty. Submitted by: vsevolod MFC after: 1 week Modified: head/usr.sbin/gstat/gstat.8 head/usr.sbin/gstat/gstat.c Modified: head/usr.sbin/gstat/gstat.8 ============================================================================== --- head/usr.sbin/gstat/gstat.8 Thu Mar 12 13:03:33 2009 (r189738) +++ head/usr.sbin/gstat/gstat.8 Thu Mar 12 13:17:46 2009 (r189739) @@ -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 Modified: head/usr.sbin/gstat/gstat.c ============================================================================== --- head/usr.sbin/gstat/gstat.c Thu Mar 12 13:03:33 2009 (r189738) +++ head/usr.sbin/gstat/gstat.c Thu Mar 12 13:17:46 2009 (r189739) @@ -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) {