summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--disk-utils/fsck.86
-rw-r--r--disk-utils/fsck.c27
-rw-r--r--disk-utils/mkfs.cramfs.88
-rw-r--r--disk-utils/mkfs.cramfs.c34
-rw-r--r--include/c.h6
-rw-r--r--login-utils/chsh.c2
-rw-r--r--login-utils/login.15
-rw-r--r--login-utils/login.c28
-rw-r--r--login-utils/lslogins.c15
-rw-r--r--misc-utils/blkid.c8
-rw-r--r--misc-utils/test_uuidd.c25
-rw-r--r--misc-utils/uuidd.c6
-rw-r--r--misc-utils/whereis.16
-rw-r--r--misc-utils/whereis.c48
-rw-r--r--sys-utils/dmesg.c4
-rw-r--r--sys-utils/setarch.c22
-rw-r--r--text-utils/hexdump.c2
-rw-r--r--text-utils/more.16
-rw-r--r--text-utils/more.c29
19 files changed, 180 insertions, 107 deletions
diff --git a/disk-utils/fsck.8 b/disk-utils/fsck.8
index 3148e4284..b3096bec6 100644
--- a/disk-utils/fsck.8
+++ b/disk-utils/fsck.8
@@ -309,6 +309,12 @@ Don't show the title on startup.
.B \-V
Produce verbose output, including all filesystem-specific commands
that are executed.
+.TP
+\fB\-?\fR, \fB\-\-help\fR
+Display help text and exit.
+.TP
+\fB\-\-version\fR
+Display version information and exit.
.SH FILESYSTEM SPECIFIC OPTIONS
.B Options which are not understood by fsck are passed to the filesystem-specific checker!
.PP
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index cb1b21278..cbe179ba6 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -1369,8 +1369,9 @@ static int check_all(void)
return status;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] -- [fs-options] [<filesystem> ...]\n"),
program_invocation_short_name);
@@ -1393,13 +1394,14 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -t <type> specify filesystem types to be checked;\n"
" <type> is allowed to be a comma-separated list\n"), out);
fputs(_(" -V explain what is being done\n"), out);
- fputs(_(" -? display this help and exit\n"), out);
fputs(USAGE_SEPARATOR, out);
+ fputs(_(" -?, --help display this help and exit\n"), out);
+ fputs(_(" --version output version information and exit\n"), out);
+ fputs(USAGE_SEPARATOR, out);
fputs(_("See the specific fsck.* commands for available fs-options."), out);
fprintf(out, USAGE_MAN_TAIL("fsck(8)"));
-
- exit(out == stderr ? FSCK_EX_USAGE : FSCK_EX_OK);
+ exit(FSCK_EX_OK);
}
static void signal_cancel(int sig __attribute__((__unused__)))
@@ -1433,6 +1435,15 @@ static void parse_argv(int argc, char *argv[])
arg = argv[i];
if (!arg)
continue;
+
+ /* the only two longopts to satisfy UL standards */
+ if (!opts_for_fsck && !strcmp(arg, "--help"))
+ usage();
+ if (!opts_for_fsck && !strcmp(arg, "--version")) {
+ printf(UTIL_LINUX_VERSION);
+ exit(FSCK_EX_OK);
+ }
+
if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) {
if (num_devices >= MAX_DEVICES)
errx(FSCK_EX_ERROR, _("too many devices"));
@@ -1536,13 +1547,15 @@ static void parse_argv(int argc, char *argv[])
case 't':
tmp = NULL;
if (fstype)
- usage(stderr);
+ errx(FSCK_EX_USAGE,
+ _("option '%s' may be specified only once"), "-t");
if (arg[j+1])
tmp = arg+j+1;
else if ((i+1) < argc)
tmp = argv[++i];
else
- usage(stderr);
+ errx(FSCK_EX_USAGE,
+ _("option '%s' requires an argument"), "-t");
fstype = xstrdup(tmp);
compile_fs_type(fstype, &fs_type_compiled);
goto next_arg;
@@ -1550,7 +1563,7 @@ static void parse_argv(int argc, char *argv[])
opts_for_fsck++;
break;
case '?':
- usage(stdout);
+ usage();
break;
default:
options[++opt] = arg[j];
diff --git a/disk-utils/mkfs.cramfs.8 b/disk-utils/mkfs.cramfs.8
index c2e843ab9..9701e1075 100644
--- a/disk-utils/mkfs.cramfs.8
+++ b/disk-utils/mkfs.cramfs.8
@@ -64,11 +64,11 @@ sorting.
\fB\-z\fR
Make explicit holes. Use of this option will require 2.3.39 kernel, or newer.
.TP
-\fB\-V\fR
-Display version information and exit.
+\fB\-h\fR, \fB\-\-help\fR
+Display help text and exit.
.TP
-\fB\-h\fR
-Display help and exit.
+\fB\-V\fR, \fB\-\-version\fR
+Display version information and exit.
.SH "EXIT STATUS"
.RS
.PD 0
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 77b4467e7..87b378c81 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -122,15 +122,11 @@ struct entry {
#define CRAMFS_GID_WIDTH 8
#define CRAMFS_OFFSET_WIDTH 26
-/* Input status of 0 to print help and exit without an error. */
-static void __attribute__((__noreturn__))
-usage(int status) {
- FILE *stream = status ? stderr : stdout;
-
- fprintf(stream,
+static void __attribute__((__noreturn__)) usage(void)
+{
+ printf(
_("usage: %s [-h] [-v] [-b blksize] [-e edition] [-N endian] [-i file] "
"[-n name] dirname outfile\n"
- " -h print this help\n"
" -v be verbose\n"
" -E make all warnings errors "
"(non-zero exit status)\n"
@@ -147,7 +143,11 @@ usage(int status) {
" outfile output file\n"),
program_invocation_short_name, PAD_SIZE);
- exit(status);
+ fputs(USAGE_SEPARATOR, stdout);
+ fputs(USAGE_HELP, stdout);
+ fputs(USAGE_VERSION, stdout);
+ printf(USAGE_MAN_TAIL("mkfs.cramfs(8)"));
+ exit(MKFS_EX_OK);
}
static char *
@@ -717,11 +717,21 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
+ if (argc > 1) {
+ /* first arg may be one of our standard longopts */
+ if (!strcmp(argv[1], "--help"))
+ usage();
+ if (!strcmp(argv[1], "--version")) {
+ printf(UTIL_LINUX_VERSION);
+ exit(MKFS_EX_OK);
+ }
+ }
+
/* command line options */
while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) {
switch (c) {
case 'h':
- usage(MKFS_EX_OK);
+ usage();
case 'b':
blksize = strtou32_or_err(optarg, _("invalid blocksize argument"));
break;
@@ -773,8 +783,10 @@ int main(int argc, char **argv)
}
}
- if ((argc - optind) != 2)
- usage(MKFS_EX_USAGE);
+ if ((argc - optind) != 2) {
+ warnx(_("bad usage"));
+ errtryhelp(MKFS_EX_USAGE);
+ }
dirname = argv[optind];
outfile = argv[optind + 1];
diff --git a/include/c.h b/include/c.h
index 2bcdcea5d..8cf54cbe4 100644
--- a/include/c.h
+++ b/include/c.h
@@ -216,12 +216,6 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
exit(eval); \
})
-#define errtryh(eval) __extension__ ({ \
- fprintf(stderr, _("Try '%s -h' for more information.\n"), \
- program_invocation_short_name); \
- exit(eval); \
-})
-
static inline __attribute__((const)) int is_power_of_2(unsigned long num)
{
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index 3bea971cd..10b0bdcda 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -235,8 +235,6 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo)
print_shells();
exit(EXIT_SUCCESS);
case 's':
- if (!optarg)
- usage(stderr);
pinfo->shell = optarg;
break;
default:
diff --git a/login-utils/login.1 b/login-utils/login.1
index 2fc7a501f..5d43fdcdd 100644
--- a/login-utils/login.1
+++ b/login-utils/login.1
@@ -131,7 +131,10 @@ to tell
.B login
that printing the hostname should be suppressed in the login: prompt.
.TP
-.B \-V
+\fB\-\-help\fR
+Display help text and exit.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
Display version information and exit.
.SH CONFIG FILE ITEMS
.B login
diff --git a/login-utils/login.c b/login-utils/login.c
index 37553ef0a..ee06d03e8 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1095,6 +1095,16 @@ static void init_remote_info(struct login_context *cxt, char *remotehost)
}
}
+static void __attribute__((__noreturn__)) usage(void)
+{
+ fputs(USAGE_HEADER, stdout);
+ printf(_(" %s [-p] [-h <host>] [-H] [[-f] <username>]\n"), program_invocation_short_name);
+ fputs(USAGE_SEPARATOR, stdout);
+ fputs(_("Begin a session on the system.\n"), stdout);
+ printf(USAGE_MAN_TAIL("login(1)"));
+ exit(EXIT_SUCCESS);
+}
+
int main(int argc, char **argv)
{
int c;
@@ -1119,6 +1129,14 @@ int main(int argc, char **argv)
};
+ /* the only two longopts to satisfy UL standards */
+ enum { HELP_OPTION = CHAR_MAX + 1 };
+ static const struct option longopts[] = {
+ {"help", no_argument, NULL, HELP_OPTION},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, 0, NULL, 0}
+ };
+
timeout = (unsigned int)getlogindefs_num("LOGIN_TIMEOUT", LOGIN_TIMEOUT);
signal(SIGALRM, timedout);
@@ -1142,7 +1160,7 @@ int main(int argc, char **argv)
* -h is used by other servers to pass the name of the remote
* host to login so that it may be placed in utmp and wtmp
*/
- while ((c = getopt(argc, argv, "fHh:pV")) != -1)
+ while ((c = getopt_long(argc, argv, "fHh:pV", longopts, NULL)) != -1)
switch (c) {
case 'f':
cxt.noauth = 1;
@@ -1168,12 +1186,10 @@ int main(int argc, char **argv)
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
- case '?':
+ case HELP_OPTION:
+ usage();
default:
- fprintf(stderr, _("Usage: login [-p] [-h <host>] [-H] [[-f] <username>]\n"));
- fputs(USAGE_SEPARATOR, stderr);
- fputs(_("Begin a session on the system.\n"), stderr);
- exit(EXIT_FAILURE);
+ errtryhelp(EXIT_FAILURE);
}
argc -= optind;
argv += optind;
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index ab04c10bb..1e89d2703 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -1381,15 +1381,12 @@ int main(int argc, char *argv[])
outmode = OUT_NEWLINE;
break;
case 'o':
- if (optarg) {
- if (*optarg == '=')
- optarg++;
- ncolumns = string_to_idarray(optarg,
- columns, ARRAY_SIZE(columns),
- column_name_to_id);
- if (ncolumns < 0)
- return EXIT_FAILURE;
- }
+ if (*optarg == '=')
+ optarg++;
+ ncolumns = string_to_idarray(optarg, columns,
+ ARRAY_SIZE(columns), column_name_to_id);
+ if (ncolumns < 0)
+ return EXIT_FAILURE;
opt_o = 1;
break;
case 'r':
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 1dc8f4085..f95f673a2 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -762,7 +762,7 @@ int main(int argc, char **argv)
case 's':
if (numtag + 1 >= sizeof(ctl.show) / sizeof(*ctl.show)) {
warnx(_("Too many tags specified"));
- errtryh(err);
+ errtryhelp(err);
}
ctl.show[numtag++] = optarg;
break;
@@ -773,13 +773,13 @@ int main(int argc, char **argv)
if (search_type) {
warnx(_("Can only search for "
"one NAME=value pair"));
- errtryh(err);
+ errtryhelp(err);
}
if (blkid_parse_tag_string(optarg,
&search_type,
&search_value)) {
warnx(_("-t needs NAME=value pair"));
- errtryh(err);
+ errtryhelp(err);
}
break;
case 'V':
@@ -794,7 +794,7 @@ int main(int argc, char **argv)
usage(0);
break;
default:
- errtryh(EXIT_FAILURE);
+ errtryhelp(EXIT_FAILURE);
}
}
diff --git a/misc-utils/test_uuidd.c b/misc-utils/test_uuidd.c
index 26751a485..7bbd3a948 100644
--- a/misc-utils/test_uuidd.c
+++ b/misc-utils/test_uuidd.c
@@ -73,17 +73,17 @@ static int shmem_id;
static object_t *objects;
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
- fprintf(out, "\n %s [options]\n", program_invocation_short_name);
+ printf("\n %s [options]\n", program_invocation_short_name);
- fprintf(out, " -p <num> number of nprocesses (default:%zu)\n", nprocesses);
- fprintf(out, " -t <num> number of nthreads (default:%zu)\n", nthreads);
- fprintf(out, " -o <num> number of nobjects (default:%zu)\n", nobjects);
- fprintf(out, " -l <level> log level (default:%zu)\n", loglev);
- fprintf(out, " -h display help\n");
+ printf(" -p <num> number of nprocesses (default:%zu)\n", nprocesses);
+ printf(" -t <num> number of nthreads (default:%zu)\n", nthreads);
+ printf(" -o <num> number of nobjects (default:%zu)\n", nobjects);
+ printf(" -l <level> log level (default:%zu)\n", loglev);
+ printf(" -h display help\n");
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void allocate_segment(int *id, void **address, size_t number, size_t size)
@@ -260,6 +260,8 @@ static void object_dump(size_t idx, object_t *obj)
fprintf(stderr, "}\n");
}
+#define MSG_TRY_HELP "Try '-h' for help."
+
int main(int argc, char *argv[])
{
size_t i, nfailed = 0, nignored = 0;
@@ -280,15 +282,16 @@ int main(int argc, char *argv[])
loglev = strtou32_or_err(optarg, "invalid log level argument");
break;
case 'h':
- usage(stdout);
+ usage();
break;
default:
- errtryh(EXIT_FAILURE);
+ fprintf(stderr, MSG_TRY_HELP);
+ exit(EXIT_FAILURE);
}
}
if (optind != argc)
- usage(stderr);
+ errx(EXIT_FAILURE, "bad usage\n" MSG_TRY_HELP);
if (loglev == 1)
fprintf(stderr, "requested: %zu processes, %zu threads, %zu objects per thread (%zu objects = %zu bytes)\n",
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 313a4afe0..371975d63 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -41,12 +41,6 @@
#include "nls.h"
-#ifdef __GNUC__
-#define CODE_ATTR(x) __attribute__(x)
-#else
-#define CODE_ATTR(x)
-#endif
-
/* length of textual representation of UUID, including trailing \0 */
#define UUID_STR_LEN 37
diff --git a/misc-utils/whereis.1 b/misc-utils/whereis.1
index 6461f2629..0d2cbe7e7 100644
--- a/misc-utils/whereis.1
+++ b/misc-utils/whereis.1
@@ -125,6 +125,12 @@ or
.BR \-S
is specified, the option will output the hard-coded paths
that the command was able to find on the system.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Display help text and exit.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Display version information and exit.
.SH EXAMPLE
To find all files in
.I /usr/\:bin
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index b5b35f5f5..897a7a213 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -183,8 +183,10 @@ static const char *whereis_type_to_name(int type)
}
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
+
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [-BMS <dir>... -f] <name>\n"), program_invocation_short_name);
@@ -201,9 +203,12 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -f terminate <dirs> argument list\n"), out);
fputs(_(" -u search for unusual entries\n"), out);
fputs(_(" -l output effective lookup paths\n"), out);
- fprintf(out, USAGE_MAN_TAIL("whereis(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+ fprintf(out, USAGE_MAN_TAIL("whereis(1)"));
+ exit(EXIT_SUCCESS);
}
static void dirlist_add_dir(struct wh_dirlist **ls0, int type, const char *dir)
@@ -502,8 +507,18 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
- if (argc == 1)
- usage(stderr);
+ if (argc <= 1) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ } else {
+ /* first arg may be one of our standard longopts */
+ if (!strcmp(argv[1], "--help"))
+ usage();
+ if (!strcmp(argv[1], "--version")) {
+ printf(UTIL_LINUX_VERSION);
+ exit(EXIT_SUCCESS);
+ }
+ }
whereis_init_debug();
@@ -547,8 +562,10 @@ int main(int argc, char **argv)
opt_f_missing = 0;
break;
case 'B':
- if (*(arg + 1))
- usage(stderr);
+ if (*(arg + 1)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
i++;
free_dirlist(&ls, BIN_DIR);
construct_dirlist_from_argv(
@@ -556,8 +573,10 @@ int main(int argc, char **argv)
opt_f_missing = 1;
break;
case 'M':
- if (*(arg + 1))
- usage(stderr);
+ if (*(arg + 1)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
i++;
free_dirlist(&ls, MAN_DIR);
construct_dirlist_from_argv(
@@ -565,8 +584,10 @@ int main(int argc, char **argv)
opt_f_missing = 1;
break;
case 'S':
- if (*(arg + 1))
- usage(stderr);
+ if (*(arg + 1)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
i++;
free_dirlist(&ls, SRC_DIR);
construct_dirlist_from_argv(
@@ -604,9 +625,10 @@ int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
- usage(stderr);
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
}
if (arg_i < i) /* moved to the next argv[] item */
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 821d8bbb2..37639ebe5 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1486,10 +1486,8 @@ int main(int argc, char *argv[])
errtryhelp(EXIT_FAILURE);
}
}
- argc -= optind;
- argv += optind;
- if (argc > 1)
+ if (argc != optind)
usage(stderr);
if ((is_timefmt(&ctl, RELTIME) ||
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index eb9cf21a0..b14dbea40 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -84,7 +84,7 @@
static int archwrapper;
-static void __attribute__((__noreturn__)) show_help(void)
+static void __attribute__((__noreturn__)) usage(void)
{
fputs(USAGE_HEADER, stdout);
if (!archwrapper)
@@ -121,17 +121,6 @@ static void __attribute__((__noreturn__)) show_help(void)
exit(EXIT_SUCCESS);
}
-static void __attribute__((__noreturn__)) show_usage(const char *s)
-{
- if (s)
- errx(EXIT_FAILURE,
- _("%s\nTry `%s --help' for more information."), s,
- program_invocation_short_name);
- else
- errx(EXIT_FAILURE, _("Try `%s --help' for more information."),
- program_invocation_short_name);
-}
-
static void __attribute__((__noreturn__))
show_version(void)
{
@@ -301,9 +290,10 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
- if (argc < 1)
- show_usage(_("Not enough arguments"));
-
+ if (argc < 1) {
+ warnx(_("Not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
archwrapper = strcmp(program_invocation_short_name, "setarch") != 0;
if (archwrapper)
arch = program_invocation_short_name; /* symlinks to setarch */
@@ -328,7 +318,7 @@ int main(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "+hVv3BFILRSTXZ", longopts, NULL)) != -1) {
switch (c) {
case 'h':
- show_help();
+ usage();
break;
case 'V':
show_version();
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index 125734dfe..bf0631654 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -107,7 +107,7 @@ parse_args(int argc, char **argv, struct hexdump *hex)
case 'f':
addfile(optarg, hex);
break;
- case 'L':
+ case 'L':
colormode = UL_COLORMODE_AUTO;
if (optarg)
colormode = colormode_or_err(optarg,
diff --git a/text-utils/more.1 b/text-utils/more.1
index 428fdecb7..c4420e09a 100644
--- a/text-utils/more.1
+++ b/text-utils/more.1
@@ -98,6 +98,12 @@ Start displaying each file at line
The
.I string
to be searched in each file before starting to display it.
+.TP
+\fB\-\-help\fR
+Display help text and exit.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Display version information and exit.
.SH COMMANDS
Interactive commands for
.B more
diff --git a/text-utils/more.c b/text-utils/more.c
index 7c197b201..35786567a 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -225,8 +225,9 @@ static void putstring(char *s)
tputs(s, fileno(stdout), putchar); /* putp(s); */
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <file>...\n"), program_invocation_short_name);
@@ -244,9 +245,12 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -<number> the number of lines per screenful\n"), out);
fputs(_(" +<number> display file beginning from line number\n"), out);
fputs(_(" +/<string> display file beginning from search string match\n"), out);
- fputs(_(" -V display version information and exit\n"), out);
+
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_(" --help display this help and exit\n"), out);
+ fputs(_(" -V, --version output version information and exit\n"), out);
fprintf(out, USAGE_MAN_TAIL("more(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
@@ -267,6 +271,16 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
+ if (argc > 1) {
+ /* first arg may be one of our standard longopts */
+ if (!strcmp(argv[1], "--help"))
+ usage();
+ if (!strcmp(argv[1], "--version")) {
+ printf(UTIL_LINUX_VERSION);
+ exit(EXIT_SUCCESS);
+ }
+ }
+
nfiles = argc;
fnames = argv;
setlocale(LC_ALL, "");
@@ -319,9 +333,10 @@ int main(int argc, char **argv)
left = dlines;
if (nfiles > 1)
prnames++;
- if (!no_intty && nfiles == 0)
- usage(stderr);
- else
+ if (!no_intty && nfiles == 0) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ } else
f = stdin;
if (!no_tty) {
signal(SIGQUIT, onquit);
@@ -488,7 +503,7 @@ void argscan(char *s)
break;
default:
warnx(_("unknown option -%s"), s);
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
break;
}
s++;