diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-10-15 20:15:48 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-10-15 20:15:48 +0000 |
commit | 39c705c4b095f3ac37094235f9c8e380bda9f4ee (patch) | |
tree | ac54c6b24950bb75c0ae480173d70ed45a148669 /bin/df | |
parent | f4d69698af65b5018d56a33b0d1ae0f55ec78a6b (diff) |
Don't print header if we didn't print any usage lines. Noticed and
tested by robert@
Diffstat (limited to 'bin/df')
-rw-r--r-- | bin/df/df.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/bin/df/df.c b/bin/df/df.c index e5a6f3bdfc6..c03f3719432 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: df.c,v 1.39 2004/09/14 22:51:47 deraadt Exp $ */ +/* $OpenBSD: df.c,v 1.40 2004/10/15 20:15:47 millert Exp $ */ /* $NetBSD: df.c,v 1.21.2.1 1995/11/01 00:06:11 jtc Exp $ */ /* @@ -45,7 +45,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: df.c,v 1.39 2004/09/14 22:51:47 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: df.c,v 1.40 2004/10/15 20:15:47 millert Exp $"; #endif #endif /* not lint */ @@ -172,22 +172,24 @@ main(int argc, char *argv[]) } } - maxwidth = 0; - for (i = 0; i < mntsize; i++) { - width = strlen(mntbuf[i].f_mntfromname); - if (width > maxwidth) - maxwidth = width; - } + if (mntsize) { + maxwidth = 0; + for (i = 0; i < mntsize; i++) { + width = strlen(mntbuf[i].f_mntfromname); + if (width > maxwidth) + maxwidth = width; + } - if (maxwidth < 11) - maxwidth = 11; + if (maxwidth < 11) + maxwidth = 11; - if (Pflag) - posixprint(mntbuf, mntsize, maxwidth); - else - bsdprint(mntbuf, mntsize, maxwidth); + if (Pflag) + posixprint(mntbuf, mntsize, maxwidth); + else + bsdprint(mntbuf, mntsize, maxwidth); + } - exit(0); + exit(mntsize ? 0 : 1); } char * |