summaryrefslogtreecommitdiff
path: root/src/du.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/du.c
parent0a6061f1f9178df1bfddaff7b25dbf5393833096 (diff)
downloadcoreutils-ee871dbed84a671bad1217b23ad3802ab023e26c.tar.xz
Add --help and --version options.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/du.c b/src/du.c
index 5543ceea8..90cb303b0 100644
--- a/src/du.c
+++ b/src/du.c
@@ -43,6 +43,7 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "version.h"
int lstat ();
int stat ();
@@ -152,9 +153,14 @@ static struct stat stat_buf;
static int (*xstat) ();
/* The exit status to use if we don't get any fatal errors. */
-
static int exit_status;
+/* 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, &opt_all, 1},
@@ -167,6 +173,8 @@ static struct option const long_options[] =
{"separate-dirs", no_argument, &opt_separate_dirs, 1},
{"summarize", no_argument, &opt_summarize_only, 1},
{"total", no_argument, &opt_combined_arguments, 1},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
@@ -253,6 +261,12 @@ main (argc, argv)
if (opt_all && opt_summarize_only)
usage ("cannot both summarize and show all entries");
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ("");
+
/* Initialize the hash structure for inode numbers. */
hash_init (INITIAL_HASH_MODULE, INITIAL_ENTRY_TAB_SIZE);