]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Add --help and --version options.
authorJim Meyering <jim@meyering.net>
Fri, 2 Apr 1993 04:26:26 +0000 (04:26 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 2 Apr 1993 04:26:26 +0000 (04:26 +0000)
16 files changed:
src/chgrp.c
src/chmod.c
src/chown.c
src/cp.c
src/dd.c
src/df.c
src/du.c
src/install.c
src/ln.c
src/mkdir.c
src/mkfifo.c
src/mknod.c
src/mv.c
src/rm.c
src/rmdir.c
src/touch.c

index 2d4fe213e1e21d2e9794d06a344a4407b2cdc7ed..2dba1eed4a4ab645995de1497bf12b5a00ac9a4a 100644 (file)
 #include <grp.h>
 #include <getopt.h>
 #include "system.h"
+#include "version.h"
 
 #if !defined (isascii) || defined (STDC_HEADERS)
+#undef isascii
 #define isascii(c) 1
 #endif
 
@@ -70,6 +72,12 @@ static int changes_only;
 /* The name of the group to which ownership of the files is being given. */
 static char *groupname;
 
+/* 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[] =
 {
   {"recursive", no_argument, 0, 'R'},
@@ -77,6 +85,8 @@ static struct option const long_options[] =
   {"silent", no_argument, 0, 'f'},
   {"quiet", no_argument, 0, 'f'},
   {"verbose", no_argument, 0, 'v'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -118,6 +128,12 @@ main (argc, argv)
   if (optind >= argc - 1)
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   parse_group (argv[optind++], &group);
 
   for (; optind < argc; ++optind)
index 3df4b99aba42fa5149fa0400949fe831a276bae9..de93b0f0ca41447fdca34aee2a1a0ae07786988b 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/types.h>
 #include "modechange.h"
 #include "system.h"
+#include "version.h"
 
 int lstat ();
 
@@ -57,6 +58,12 @@ static int verbose;
 /* If nonzero, describe only modes that change. */
 static int changes_only;
 
+/* 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[] =
 {
   {"recursive", no_argument, 0, 'R'},
@@ -64,6 +71,8 @@ static struct option const long_options[] =
   {"silent", no_argument, 0, 'f'},
   {"quiet", no_argument, 0, 'f'},
   {"verbose", no_argument, 0, 'v'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -136,6 +145,12 @@ main (argc, argv)
   if (optind >= argc)
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   changes = mode_compile (argv[modeind],
                          MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS);
   if (changes == MODE_INVALID)
index 37a881e2fd265f0a76bb5a7ba5c325ab82d24e70..e693e662a3115108550c910801ed45c0f484f87d 100644 (file)
@@ -35,6 +35,7 @@
 #include <grp.h>
 #include <getopt.h>
 #include "system.h"
+#include "version.h"
 
 #ifndef _POSIX_VERSION
 struct passwd *getpwnam ();
@@ -81,6 +82,12 @@ static char *username;
 /* The name of the group to which ownership of the files is being given. */
 static char *groupname;
 
+/* 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[] =
 {
   {"recursive", no_argument, 0, 'R'},
@@ -88,6 +95,8 @@ static struct option const long_options[] =
   {"silent", no_argument, 0, 'f'},
   {"quiet", no_argument, 0, 'f'},
   {"verbose", no_argument, 0, 'v'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -131,6 +140,12 @@ main (argc, argv)
   if (optind >= argc - 1)
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   e = parse_user_spec (argv[optind], &user, &group, &username, &groupname);
   if (e)
     error (1, 0, "%s: %s", argv[optind], e);
index 9eef69c9fbd4c04c506226436e2f1ab12505be21..f3a7c0a974fbfb79370ef5fd7a9008235526b3f7 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -24,6 +24,7 @@
 #include <getopt.h>
 #include "cp.h"
 #include "backupfile.h"
+#include "version.h"
 
 #ifndef _POSIX_VERSION
 uid_t geteuid ();
@@ -56,13 +57,13 @@ static int re_protect ();
 /* Initial number of entries in the inode hash table.  */
 #define INITIAL_ENTRY_TAB_SIZE 70
 
+/* The invocation name of this program.  */
+char *program_name;
+
 /* A pointer to either lstat or stat, depending on
    whether dereferencing of symlinks is done.  */
 static int (*xstat) ();
 
-/* The invocation name of this program.  */
-char *program_name;
-
 /* If nonzero, copy all files except directories and, if not dereferencing
    them, symbolic links, as if they were regular files. */
 static int flag_copy_as_regular = 1;
@@ -117,6 +118,12 @@ static int umask_kill;
 /* This process's effective user ID.  */
 static uid_t myeuid;
 
+/* 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_opts[] =
 {
   {"archive", no_argument, NULL, 'a'},
@@ -134,6 +141,8 @@ static struct option const long_opts[] =
   {"update", no_argument, &flag_update, 1},
   {"verbose", no_argument, &flag_verbose, 1},
   {"version-control", required_argument, NULL, 'V'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 \f
@@ -252,6 +261,12 @@ main (argc, argv)
   if (flag_hard_link && flag_symbolic_link)
     usage ("cannot make both hard and symbolic links");
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage (NULL);
+
   if (make_backups)
     backup_type = get_version (version);
 
index c8a433740a6f98371e3eff8ed1d3f15c268176ba..cdf5234fd0d261a7a657243c04bb6493ee1c5fa3 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -57,6 +57,7 @@
 #include <ctype.h>
 
 #if !defined (isascii) || defined (STDC_HEADERS)
+#undef isascii
 #define isascii(c) 1
 #endif
 
@@ -307,7 +308,10 @@ static unsigned char const ebcdic_to_ascii[] =
   070, 071, 0372, 0373, 0374, 0375, 0376, 0377
 };
 
+/* 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[] =
@@ -337,7 +341,7 @@ main (argc, argv)
   scanargs (argc, argv);
 
   if (flag_version)
-    fprintf (stderr, "%s", version_string);
+    fprintf (stderr, "%s\n", version_string);
 
   if (flag_help)
     usage ("", NULL, NULL);
index 994987f3f55b4b7199610be51295d642da1ebc49..bdc834cac71a8e152426d9dd8a260dbbd47cc578 100644 (file)
--- 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. */
index 5543ceea86c68c59ed52cf80f71ae77c35fa54d7..90cb303b0bab95a6a0c6c484ed2ec09cbcc4a4cc 100644 (file)
--- 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);
 
index 4fccb844724f6b338238ce6d2d0c7fc5439e6bcc..dd8b58cc73c21076d7e6075dd4dac4f0be531b43 100644 (file)
 #include <pwd.h>
 #include <grp.h>
 #include "system.h"
+#include "version.h"
 #include "modechange.h"
 
 #if !defined (isascii) || defined (STDC_HEADERS)
+#undef isascii
 #define isascii(c) 1
 #endif
 
@@ -130,6 +132,12 @@ static int strip_files;
 /* If nonzero, install a directory instead of a regular file. */
 static int dir_arg;
 
+/* 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[] =
 {
   {"strip", no_argument, NULL, 's'},
@@ -137,6 +145,8 @@ static struct option const long_options[] =
   {"group", required_argument, NULL, 'g'},
   {"mode", required_argument, NULL, 'm'},
   {"owner", required_argument, NULL, 'o'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -190,6 +200,12 @@ main (argc, argv)
       || (optind == argc - 1 && !dir_arg))
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   if (symbolic_mode)
     {
       struct mode_change *change = mode_compile (symbolic_mode, 0);
index 3907399ee4240fb0dd6a3b9ef98b33c6cdbf4a4b..67341036374ffacf404853320bebf8b5aab11e93 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -25,6 +25,7 @@
 #include <getopt.h>
 #include "system.h"
 #include "backupfile.h"
+#include "version.h"
 
 int link ();                   /* Some systems don't declare this anywhere. */
 
@@ -41,6 +42,9 @@ void error ();
 static void usage ();
 static int do_link ();
 
+/* The name by which the program was run, for error messages.  */
+char *program_name;
+
 /* A pointer to the function used to make links.  This will point to either
    `link' or `symlink'. */
 static int (*linkfunc) ();
@@ -60,8 +64,11 @@ static int verbose;
 /* If nonzero, allow the superuser to make hard links to directories. */
 static int hard_dir_link;
 
-/* The name by which the program was run, for error messages.  */
-char *program_name;
+/* 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[] = 
 {
@@ -73,6 +80,8 @@ static struct option const long_options[] =
   {"symbolic", no_argument, &symbolic_link, 1},
   {"verbose", no_argument, &verbose, 1},
   {"version-control", required_argument, NULL, 'V'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -142,6 +151,12 @@ main (argc, argv)
   if (optind == argc)
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   if (make_backups)
     backup_type = get_version (version);
 
index 00bde815fad109c3bfde2724606511e777300516..3d98ac6271e7902c78f2b9e3b5ef8be6d21eae88 100644 (file)
 #include <sys/types.h>
 #include "system.h"
 #include "modechange.h"
+#include "version.h"
 
 int make_path ();
 void error ();
 
 static void usage ();
 
+/* The name this program was run with. */
+char *program_name;
+
 /* If nonzero, ensure that a path exists.  */
 static int path_mode;
 
-/* The name this program was run with. */
-char *program_name;
+/* 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 longopts[] =
 {
   {"mode", required_argument, NULL, 'm'},
   {"path", no_argument, &path_mode, 1},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -84,7 +93,13 @@ main (argc, argv)
 
   if (optind == argc)
     usage ();
-  
+
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   newmode = 0777 & ~umask (0);
   parent_mode = newmode | 0300;        /* u+wx */
   if (symbolic_mode)
index 075cece515bd4208acde2c53e73fb9b1341501ca..a6a78f105f57d3f895c7ab4bd255acffb2373035 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/types.h>
 #include "system.h"
 #include "modechange.h"
+#include "version.h"
 
 void error ();
 
@@ -35,9 +36,17 @@ static void usage ();
 /* The name this program was run with. */
 char *program_name;
 
+/* 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 longopts[] =
 {
   {"mode", required_argument, NULL, 'm'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -72,7 +81,13 @@ main (argc, argv)
 
   if (optind == argc)
     usage ();
-  
+
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   newmode = 0666 & ~umask (0);
   if (symbolic_mode)
     {
index 66029ad0f6f0a4d29ea271e67fd636d35317587b..7e65ac01f5e6438ddef8cc9d161126535d757902 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include "system.h"
 #include "modechange.h"
+#include "version.h"
 
 void error ();
 
@@ -40,9 +41,17 @@ static void usage ();
 /* The name this program was run with. */
 char *program_name;
 
+/* 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 longopts[] =
 {
   {"mode", required_argument, NULL, 'm'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -71,6 +80,12 @@ main (argc, argv)
        }
     }
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   newmode = 0666 & ~umask (0);
   if (symbolic_mode)
     {
index 9d28d4a87f3f9362b8981bf10988b17c19cb6d4b..91906e1393e14a7c5b8a6048d5ad6cc9f8035b5a 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
@@ -45,6 +45,7 @@
 #include <sys/types.h>
 #include "system.h"
 #include "backupfile.h"
+#include "version.h"
 
 #ifndef _POSIX_VERSION
 uid_t geteuid ();
@@ -86,6 +87,12 @@ static int stdin_tty;
 /* This process's effective user ID.  */
 static uid_t myeuid;
 
+/* 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[] =
 {
   {"backup", no_argument, NULL, 'b'},
@@ -95,6 +102,8 @@ static struct option const long_options[] =
   {"update", no_argument, &update, 1},
   {"verbose", no_argument, &verbose, 1},
   {"version-control", required_argument, NULL, 'V'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -154,6 +163,12 @@ main (argc, argv)
   if (argc < optind + 2)
     usage ();
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   if (make_backups)
     backup_type = get_version (version);
 
index 4b6c2d2ebd1254e95262ca840f7d2972c243b682..0dec9d133ea14f6b706cfae53ca1f05fd0a7836b 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -21,6 +21,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include "system.h"
+#include "version.h"
 
 #ifdef _POSIX_SOURCE
 /* POSIX.1 doesn't have inodes, so fake them to avoid lots of ifdefs. */
@@ -46,6 +47,9 @@ static int remove_file ();
 static int rm ();
 static void usage ();
 
+/* Name this program was run with.  */
+char *program_name;
+
 /* Path of file now being processed; extended as necessary. */
 static char *pathname;
 
@@ -53,9 +57,6 @@ static char *pathname;
    made larger when necessary, but never smaller.  */
 static int pnsize;
 
-/* Name this program was run with.  */
-char *program_name;
-
 /* If nonzero, display the name of each file removed. */
 static int verbose;
 
@@ -76,6 +77,12 @@ static int unlink_dirs;
 /* If nonzero, stdin is a tty. */
 static int stdin_tty;
 
+/* 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_opts[] =
 {
   {"directory", no_argument, &unlink_dirs, 1},
@@ -83,6 +90,8 @@ static struct option const long_opts[] =
   {"interactive", no_argument, NULL, 'i'},
   {"recursive", no_argument, &recursive, 1},
   {"verbose", no_argument, &verbose, 1},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -129,6 +138,12 @@ main (argc, argv)
        }
     }
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   if (optind == argc)
     {
       if (ignore_missing_files)
index 35bd7d652b91a9956eb0341705d54417a422e7d1..aaaeb4df6e89f8b7a634adb0de9b35785786bb43 100644 (file)
@@ -26,6 +26,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include "system.h"
+#include "version.h"
 
 void error ();
 void strip_trailing_slashes ();
@@ -33,15 +34,23 @@ void strip_trailing_slashes ();
 static void remove_parents ();
 static void usage ();
 
+/* The name this program was run with. */
+char *program_name;
+
 /* If nonzero, remove empty parent directories. */
 static int empty_paths;
 
-/* The name this program was run with. */
-char *program_name;
+/* 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 longopts[] =
 {
   {"path", no_argument, &empty_paths, 1},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -72,7 +81,13 @@ main (argc, argv)
 
   if (optind == argc)
     usage ();
-  
+
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   for (; optind < argc; ++optind)
     {
       /* Stripping slashes is harmless for rmdir;
index 65d76279fb31217bba00df78fcc5dfaecb3ddeb8..7be500bdf30476d03e8ccf7c547b839e4185aa28 100644 (file)
@@ -37,6 +37,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include "system.h"
+#include "version.h"
 
 #ifdef STDC_HEADERS
 #include <time.h>
@@ -61,6 +62,9 @@ static int utime_now ();
 #define CH_ATIME 1
 #define CH_MTIME 2
 
+/* The name by which this program was run. */
+char *program_name;
+
 /* Which timestamps to change. */
 static int change_times;
 
@@ -90,8 +94,11 @@ static char *ref_file;
 /* Info about the reference file. */
 static struct stat ref_stats;
 
-/* The name by which this program was run. */
-char *program_name;
+/* 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 longopts[] =
 {
@@ -99,6 +106,8 @@ static struct option const longopts[] =
   {"no-create", no_argument, 0, 'c'},
   {"date", required_argument, 0, 'd'},
   {"file", required_argument, 0, 'r'},
+  {"help", no_argument, &flag_help, 1},
+  {"version", no_argument, &flag_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -183,6 +192,12 @@ main (argc, argv)
        }
     }
 
+  if (flag_version)
+    fprintf (stderr, "%s\n", version_string);
+
+  if (flag_help)
+    usage ();
+
   if (change_times == 0)
     change_times = CH_ATIME | CH_MTIME;