summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-02-11 10:08:28 +0000
committerJim Meyering <jim@meyering.net>2000-02-11 10:08:28 +0000
commitd89210720b1a67f9a73aadd53b31650774ad302f (patch)
treeea028dabab5befbf43cb948d838d435a4b9101c1 /src
parent1347ab3fa27e5f6e2511bb93c9200e0e6fcd606c (diff)
downloadcoreutils-d89210720b1a67f9a73aadd53b31650774ad302f.tar.xz
(main): Count the stat'able arguments.
Print the header line only if there is at least one valid argument. Reported by Andy Longton <alongton@metamark.com>
Diffstat (limited to 'src')
-rw-r--r--src/df.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/df.c b/src/df.c
index 6cf22efbb..885c26264 100644
--- a/src/df.c
+++ b/src/df.c
@@ -762,6 +762,7 @@ main (int argc, char **argv)
{
int c;
struct stat *stats IF_LINT (= 0);
+ int n_valid_args = 0;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -877,12 +878,18 @@ main (int argc, char **argv)
stats = (struct stat *)
xmalloc ((argc - optind) * sizeof (struct stat));
for (i = optind; i < argc; ++i)
- if (stat (argv[i], &stats[i - optind]))
- {
- error (0, errno, "%s", argv[i]);
- exit_status = 1;
- argv[i] = NULL;
- }
+ {
+ if (stat (argv[i], &stats[i - optind]))
+ {
+ error (0, errno, "%s", argv[i]);
+ exit_status = 1;
+ argv[i] = NULL;
+ }
+ else
+ {
+ ++n_valid_args;
+ }
+ }
}
mount_list =
@@ -917,7 +924,9 @@ main (int argc, char **argv)
/* Display explicitly requested empty filesystems. */
show_listed_fs = 1;
- print_header ();
+ if (n_valid_args > 0)
+ print_header ();
+
for (i = optind; i < argc; ++i)
if (argv[i])
show_entry (argv[i], &stats[i - optind]);