]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Include long-options.h.
authorJim Meyering <jim@meyering.net>
Sat, 6 Mar 1999 15:28:54 +0000 (15:28 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 6 Mar 1999 15:28:54 +0000 (15:28 +0000)
[long_options]: Remove the "help" and "version" entries.
Remove declarations of show_help and show_version.
(main): Use parse_long_options, including author name(s).
Remove the show_version and show_help blocks.

login-utils/su.c

index f1a8bb92def4a5157e1c3b6a5ad2d3bdb3774277..3d32a57b7b3cac55744dceded16f89a4e0b1da3a 100644 (file)
@@ -82,6 +82,7 @@
 #define getusershell _getusershell_sys_proto_
 
 #include "system.h"
+#include "long-options.h"
 
 #undef getusershell
 
@@ -152,12 +153,6 @@ extern char **environ;
 /* The name this program was run with.  */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* If nonzero, pass the `-f' option to the subshell.  */
 static int fast_startup;
 
@@ -171,11 +166,9 @@ static struct option const longopts[] =
 {
   {"command", required_argument, 0, 'c'},
   {"fast", no_argument, NULL, 'f'},
-  {"help", no_argument, &show_help, 1},
   {"login", no_argument, NULL, 'l'},
   {"preserve-environment", no_argument, &change_environment, 0},
   {"shell", required_argument, 0, 's'},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -467,6 +460,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "su", GNU_PACKAGE, VERSION,
+                     "David MacKenzie", usage);
+
   fast_startup = 0;
   simulate_login = 0;
   change_environment = 1;
@@ -504,15 +500,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("su (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind < argc && !strcmp (argv[optind], "-"))
     {
       simulate_login = 1;