mirror of
https://github.com/coreutils/coreutils.git
synced 2025-01-18 22:13:24 +08:00
Include long-options.h.
[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.
This commit is contained in:
parent
782b270314
commit
5b2aa1846b
23
src/date.c
23
src/date.c
@ -24,9 +24,10 @@
|
||||
|
||||
#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
|
||||
@ -44,12 +45,6 @@ static void show_date PARAMS ((const char *format, time_t when));
|
||||
/* 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;
|
||||
|
||||
@ -60,14 +55,12 @@ static struct option const long_options[] =
|
||||
{
|
||||
{"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}
|
||||
};
|
||||
|
||||
@ -287,6 +280,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -316,15 +312,6 @@ main (int argc, char **argv)
|
||||
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)
|
||||
|
21
src/env.c
21
src/env.c
@ -85,6 +85,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
int putenv ();
|
||||
|
||||
@ -93,18 +94,10 @@ extern char **environ;
|
||||
/* 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}
|
||||
};
|
||||
|
||||
@ -146,6 +139,9 @@ main (register int argc, register char **argv, char **envp)
|
||||
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)
|
||||
@ -162,15 +158,6 @@ main (register int argc, register char **argv, char **envp)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
21
src/id.c
21
src/id.c
@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
struct passwd *getpwuid ();
|
||||
@ -70,21 +71,13 @@ static gid_t rgid, egid;
|
||||
/* 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}
|
||||
};
|
||||
|
||||
@ -126,6 +119,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -155,15 +151,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
|
@ -21,20 +21,13 @@
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -69,6 +62,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -81,15 +77,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("logname (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (argc - optind != 0)
|
||||
usage (1);
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
# ifndef PATH_MAX
|
||||
@ -96,17 +97,8 @@ static int validate_path PARAMS ((char *path, int portability));
|
||||
/* 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}
|
||||
};
|
||||
|
||||
@ -143,6 +135,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -159,15 +154,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
|
24
src/pinky.c
24
src/pinky.c
@ -24,6 +24,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "readutmp.h"
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
@ -40,12 +41,6 @@ char *ttyname ();
|
||||
/* 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. */
|
||||
@ -77,8 +72,6 @@ static int include_where = 1;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"help", no_argument, &show_help, 1},
|
||||
{"version", no_argument, &show_version, 1},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@ -433,7 +426,7 @@ The utmp file will be %s.\n\
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *const argv[])
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc, longind;
|
||||
|
||||
@ -442,6 +435,10 @@ main (int argc, char *const argv[])
|
||||
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)
|
||||
{
|
||||
@ -498,15 +495,6 @@ main (int argc, char *const argv[])
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -35,20 +35,13 @@
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -88,6 +81,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -100,15 +96,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
24
src/seq.c
24
src/seq.c
@ -25,6 +25,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "xstrtod.h"
|
||||
|
||||
static double scan_double_arg PARAMS ((const char *arg));
|
||||
@ -52,12 +53,6 @@ static char *separator;
|
||||
/* 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;
|
||||
|
||||
@ -68,9 +63,7 @@ static struct option const long_options[] =
|
||||
{
|
||||
{ "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}
|
||||
};
|
||||
|
||||
@ -119,6 +112,9 @@ main (int argc, char **argv)
|
||||
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";
|
||||
@ -162,18 +158,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
|
21
src/sleep.c
21
src/sleep.c
@ -22,22 +22,15 @@
|
||||
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -73,6 +66,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -85,15 +81,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
|
21
src/su.c
21
src/su.c
@ -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;
|
||||
|
22
src/tee.c
22
src/tee.c
@ -26,6 +26,7 @@
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
int full_write ();
|
||||
|
||||
@ -40,18 +41,10 @@ static int ignore_interrupts;
|
||||
/* 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}
|
||||
};
|
||||
|
||||
@ -88,6 +81,10 @@ main (int argc, char **argv)
|
||||
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;
|
||||
|
||||
@ -111,15 +108,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("tee (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (ignore_interrupts)
|
||||
{
|
||||
#ifdef _POSIX_SOURCE
|
||||
|
21
src/tty.c
21
src/tty.c
@ -30,6 +30,7 @@
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
/* The name under which this program was run. */
|
||||
char *program_name;
|
||||
@ -37,18 +38,10 @@ 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}
|
||||
};
|
||||
|
||||
@ -84,6 +77,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -102,15 +98,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("tty (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind != argc)
|
||||
usage (2);
|
||||
|
||||
|
21
src/uname.c
21
src/uname.c
@ -40,6 +40,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
|
||||
static void print_element PARAMS ((unsigned int mask, char *element));
|
||||
|
||||
@ -68,21 +69,13 @@ static unsigned char toprint;
|
||||
/* 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}
|
||||
};
|
||||
@ -125,6 +118,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -168,15 +164,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("uname (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind != argc)
|
||||
usage (1);
|
||||
|
||||
|
21
src/uptime.c
21
src/uptime.c
@ -22,22 +22,15 @@
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -190,6 +183,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -202,15 +198,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("uptime (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
switch (argc - optind)
|
||||
{
|
||||
case 0: /* uptime */
|
||||
|
21
src/users.c
21
src/users.c
@ -22,22 +22,15 @@
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -136,6 +129,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -148,15 +144,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("users (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
switch (argc - optind)
|
||||
{
|
||||
case 0: /* users */
|
||||
|
24
src/who.c
24
src/who.c
@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
|
||||
@ -46,12 +47,6 @@ char *ttyname ();
|
||||
/* 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;
|
||||
|
||||
@ -81,8 +76,6 @@ static struct option const longopts[] =
|
||||
{"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}
|
||||
};
|
||||
|
||||
@ -390,7 +383,11 @@ main (int argc, char **argv)
|
||||
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)
|
||||
{
|
||||
@ -431,15 +428,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("who (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
switch (argc - optind)
|
||||
{
|
||||
case 0: /* who */
|
||||
|
21
src/whoami.c
21
src/whoami.c
@ -25,20 +25,13 @@
|
||||
#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}
|
||||
};
|
||||
|
||||
@ -74,6 +67,9 @@ main (int argc, char **argv)
|
||||
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)
|
||||
@ -86,15 +82,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (show_version)
|
||||
{
|
||||
printf ("whoami (%s) %s\n", GNU_PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (show_help)
|
||||
usage (0);
|
||||
|
||||
if (optind != argc)
|
||||
usage (1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user