[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.
#include "system.h"
#include "closeout.h"
-#include "getline.h"
#include "error.h"
#include "getdate.h"
+#include "getline.h"
+#include "long-options.h"
#include "posixtm.h"
#ifndef STDC_HEADERS
/* The name this program was run with, for error messages. */
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 non-zero, display time in RFC-822 format for mail or news. */
static int rfc_format = 0;
{
{"date", required_argument, NULL, 'd'},
{"file", required_argument, NULL, 'f'},
- {"help", no_argument, &show_help, 1},
{"reference", required_argument, NULL, 'r'},
{"rfc-822", no_argument, NULL, 'R'},
{"set", required_argument, NULL, 's'},
{"uct", no_argument, NULL, 'u'},
{"utc", no_argument, NULL, 'u'},
{"universal", no_argument, NULL, 'u'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "date", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "d:f:r:Rs:u", long_options, NULL))
!= -1)
switch (optc)
usage (1);
}
- if (show_version)
- {
- printf ("date (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
n_args = argc - optind;
option_specified_date = ((datestr ? 1 : 0)
#include "system.h"
#include "error.h"
+#include "long-options.h"
int putenv ();
/* The name by which this program was run. */
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;
-
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
{"ignore-environment", no_argument, NULL, 'i'},
{"unset", required_argument, NULL, 'u'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "env", GNU_PACKAGE, VERSION,
+ "Richard Mlynarik and David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("env (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind != argc && !strcmp (argv[optind], "-"))
ignore_environment = 1;
#include "system.h"
#include "error.h"
+#include "long-options.h"
#ifndef _POSIX_VERSION
struct passwd *getpwuid ();
/* The number of errors encountered so far. */
static int problems = 0;
-/* 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;
-
static struct option const longopts[] =
{
{"group", no_argument, NULL, 'g'},
{"groups", no_argument, NULL, 'G'},
- {"help", no_argument, &show_help, 1},
{"name", no_argument, NULL, 'n'},
{"real", no_argument, NULL, 'r'},
{"user", no_argument, NULL, 'u'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "id", GNU_PACKAGE, VERSION,
+ "Arnold Robbins and David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "agnruG", longopts, NULL)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("id (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (just_user + just_group + just_group_list > 1)
error (1, 0, _("cannot print only user and only group"));
#include <getopt.h>
#include "system.h"
+#include "long-options.h"
/* 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;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "logname", GNU_PACKAGE, VERSION,
+ "FIXME: unknown", usage);
+
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("logname (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (argc - optind != 0)
usage (1);
#include "system.h"
#include "error.h"
+#include "long-options.h"
#ifdef _POSIX_VERSION
# ifndef PATH_MAX
/* 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;
-
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
- {"portability", no_argument, NULL, 'p'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "pathchk", GNU_PACKAGE, VERSION,
+ "David MacKenzie and Jim Meyering", usage);
+
while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("pathchk (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind == argc)
{
error (0, 0, _("too few arguments"));
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "readutmp.h"
#ifndef MAXHOSTNAMELEN
/* The name this program was run with. */
const 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, display the hours:minutes since each user has touched
the keyboard, or blank if within the last minute, or days followed
by a 'd' if not within the last day. */
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
}
int
-main (int argc, char *const argv[])
+main (int argc, char **argv)
{
int optc, longind;
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "pinky", GNU_PACKAGE, VERSION,
+ "Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi",
+ usage);
+
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, &longind))
!= -1)
{
}
}
- if (show_version)
- {
- printf ("pinky (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (do_short_format)
short_pinky (UTMP_FILE, argc - optind, argv + optind);
else
#include "system.h"
#include "closeout.h"
#include "error.h"
+#include "long-options.h"
/* 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;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "printenv", GNU_PACKAGE, VERSION,
+ "David MacKenzie and Richard Mlynarik", usage);
+
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("printenv (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind == argc)
{
for (env = environ; *env != NULL; ++env)
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "xstrtod.h"
static double scan_double_arg PARAMS ((const char *arg));
/* FIXME: make this an option. */
static char *terminator = "\n";
-/* 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;
-
/* The increment. */
static double step;
{
{ "equal-width", no_argument, NULL, 'w'},
{ "format", required_argument, NULL, 'f'},
- { "help", no_argument, &show_help, 1},
{ "separator", required_argument, NULL, 's'},
- { "version", no_argument, &show_version, 1},
{ NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "seq", GNU_PACKAGE, VERSION,
+ "Ulrich Drepper", usage);
+
equal_width = 0;
format_str = NULL;
separator = "\n";
}
}
- if (show_version)
- {
- printf ("seq (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- {
- usage (0);
- /* NOTREACHED */
- }
-
if (optind >= argc)
{
error (0, 0, _("too few arguments"));
#include "system.h"
#include "error.h"
+#include "long-options.h"
static long argdecode PARAMS ((const char *s));
/* The name by which this program was run. */
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;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "sleep", GNU_PACKAGE, VERSION,
+ "FIXME: unknown", usage);
+
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("sleep (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (argc == 1)
{
error (0, 0, _("too few arguments"));
#define getusershell _getusershell_sys_proto_
#include "system.h"
+#include "long-options.h"
#undef getusershell
/* 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;
{
{"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}
};
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;
}
}
- 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;
#include "system.h"
#include "closeout.h"
#include "error.h"
+#include "long-options.h"
int full_write ();
/* The name that 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;
-
static struct option const long_options[] =
{
{"append", no_argument, NULL, 'a'},
- {"help", no_argument, &show_help, 1},
{"ignore-interrupts", no_argument, NULL, 'i'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "tee", GNU_PACKAGE, VERSION,
+ "Mike Parker, Richard M. Stallman, and David MacKenzie",
+ usage);
+
append = 0;
ignore_interrupts = 0;
}
}
- if (show_version)
- {
- printf ("tee (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (ignore_interrupts)
{
#ifdef _POSIX_SOURCE
#include "system.h"
#include "closeout.h"
#include "error.h"
+#include "long-options.h"
/* The name under which this program was run. */
char *program_name;
/* If nonzero, return an exit status but produce no output. */
static int silent;
-/* 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;
-
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
{"silent", no_argument, NULL, 's'},
{"quiet", no_argument, NULL, 's'},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "tty", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
silent = 0;
while ((optc = getopt_long (argc, argv, "s", longopts, NULL)) != -1)
}
}
- if (show_version)
- {
- printf ("tty (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind != argc)
usage (2);
#include "system.h"
#include "error.h"
+#include "long-options.h"
static void print_element PARAMS ((unsigned int mask, char *element));
/* The name this program was run with, for error messages. */
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;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
{"machine", no_argument, NULL, 'm'},
{"nodename", no_argument, NULL, 'n'},
{"release", no_argument, NULL, 'r'},
{"sysname", no_argument, NULL, 's'},
{"processor", no_argument, NULL, 'p'},
- {"version", no_argument, &show_version, 1},
{"all", no_argument, NULL, 'a'},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "uname", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
toprint = 0;
while ((c = getopt_long (argc, argv, "snrvpma", long_options, NULL)) != -1)
}
}
- if (show_version)
- {
- printf ("uname (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind != argc)
usage (1);
#include <stdio.h>
#include "error.h"
+#include "long-options.h"
#include "readutmp.h"
#include "system.h"
/* 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;
-
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "uptime", GNU_PACKAGE, VERSION,
+ "Joseph Arceneaux and David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("uptime (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
switch (argc - optind)
{
case 0: /* uptime */
#include <stdio.h>
#include "error.h"
+#include "long-options.h"
#include "readutmp.h"
#include "system.h"
/* 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;
-
static struct option const longopts[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "users", GNU_PACKAGE, VERSION,
+ "Joseph Arceneaux and David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("users (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
switch (argc - optind)
{
case 0: /* users */
#include <stdio.h>
#include "error.h"
+#include "long-options.h"
#include "readutmp.h"
#include "system.h"
/* 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, attempt to canonicalize hostnames via a DNS lookup. */
static int do_lookup;
{"message", no_argument, NULL, 'T'},
{"mesg", no_argument, NULL, 'T'},
{"writable", no_argument, NULL, 'T'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- while ((optc = getopt_long (argc, argv, "ilmqsuwHT", longopts, &longind)) != -1)
+ parse_long_options (argc, argv, "who", GNU_PACKAGE, VERSION,
+ "Joseph Arceneaux and David MacKenzie", usage);
+
+ while ((optc = getopt_long (argc, argv, "ilmqsuwHT", longopts, &longind))
+ != -1)
{
switch (optc)
{
}
}
- if (show_version)
- {
- printf ("who (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
switch (argc - optind)
{
case 0: /* who */
#include <getopt.h>
#include "system.h"
+#include "long-options.h"
/* 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;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "whoami", GNU_PACKAGE, VERSION,
+ "Richard Mlynarik", usage);
+
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("whoami (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
if (optind != argc)
usage (1);