2006-07-20 Jim Meyering <jim@meyering.net>
+ * src/df.c (main): Fail and don't print the headers if no
+ file system is processed. This makes it easy to test whether
+ a specified directory is on a file system of a given type or types.
+ Otherwise, applications would have had to parse df's output.
+ E.g., is "." either ext3 or reiserfs: df -t ext3 -t reiserfs .
+
Fix a bug: ls --file-type worked like --indicator-style=slash,
rather than like --indicator-style=file-type.
* src/ls.c (FILE_TYPE_INDICATOR_OPTION): New enum member.
/* If true, use the POSIX output format. */
static bool posix_format;
+/* Count the number of valid arguments. */
+unsigned int n_valid_args;
+
/* If true, invoke the `sync' system call before getting any usage data.
Using this option can make df very slow, especially with many or very
busy disks. Note that this may make a difference on some systems --
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
+ ++n_valid_args;
+
/* If MOUNT_POINT is NULL, then the file system is not mounted, and this
program reports on the file system that the special file is on.
It would be better to report on the unmounted file system,
{
int c;
struct stat *stats IF_LINT (= 0);
- int n_valid_args = 0;
initialize_main (&argc, &argv);
program_name = argv[0];
exit_status = EXIT_FAILURE;
argv[i] = NULL;
}
- else
- {
- ++n_valid_args;
- }
}
}
show_all_entries ();
}
+ if (n_valid_args == 0)
+ error (EXIT_FAILURE, 0, _("no file systems processed"));
+
exit (exit_status);
}