summaryrefslogtreecommitdiff
path: root/src/df.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-04-02 04:26:26 +0000
committerJim Meyering <jim@meyering.net>1993-04-02 04:26:26 +0000
commitee871dbed84a671bad1217b23ad3802ab023e26c (patch)
treee35f1c605334d3d40c2ea1cd67fada6cd41d9d62 /src/df.c
parent0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff)
downloadcoreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz
Add --help and --version options.
Diffstat (limited to 'src/df.c')
-rw-r--r--src/df.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/df.c b/src/df.c
index 994987f3f..bdc834cac 100644
--- a/src/df.c
+++ b/src/df.c
@@ -37,6 +37,7 @@
#include "mountlist.h"
#include "fsusage.h"
#include "system.h"
+#include "version.h"
char *strstr ();
char *xmalloc ();
@@ -55,6 +56,9 @@ static void show_disk ();
static void show_point ();
static void usage ();
+/* Name this program was run with. */
+char *program_name;
+
/* If nonzero, show inode information. */
static int inode_format;
@@ -71,9 +75,6 @@ static int posix_format;
/* Nonzero if errors have occurred. */
static int exit_status;
-/* Name this program was run with. */
-char *program_name;
-
/* A filesystem type to display. */
struct fs_type_list
@@ -103,6 +104,12 @@ static struct fs_type_list *fs_exclude_list;
/* Linked list of mounted filesystems. */
static struct mount_entry *mount_list;
+/* If non-zero, display usage information and exit. */
+static int flag_help;
+
+/* If non-zero, print the version on standard error. */
+static int flag_version;
+
static struct option const long_options[] =
{
{"all", no_argument, &show_all_fs, 1},
@@ -111,6 +118,8 @@ static struct option const long_options[] =
{"portability", no_argument, &posix_format, 1},
{"type", required_argument, 0, 't'},
{"exclude-type", required_argument, 0, 'x'},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
@@ -163,6 +172,12 @@ main (argc, argv)
}
}
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (optind != argc)
{
/* Display explicitly requested empty filesystems. */