+Mon Oct 25 19:22:58 EDT 1993
+
+ * stty.c (main, integer_arg): Don't just call error(1,... about
+ improper usage. Call `error (0,...' them usage (1).
+
Sun Oct 24 14:10:23 1993 Jim Meyering (meyering@comco.com)
+ * test.c [member]: Don't try to cast index return value to an int.
+ That can lose on systems with 64-bit pointers.
+
* long-options.c: Save and restore optind, too.
* long-options.h: New file.
* long-options.c, echo.c, expr.c, printf.c, test.c, yes.c:
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH [SUFFIX]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... PATH [SUFFIX]\n", program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
+ printf ("Usage: %s [OPTION]... [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n",
+ program_name);
printf ("\
\n\
- -d, --date STRING display time described by STRING, not `now'\n\
- -s, --set STRING set time described by STRING\n\
+ -d, --date=STRING display time described by STRING, not `now'\n\
+ -s, --set=STRING set time described by STRING\n\
-u, --uct, --universal print or set Universal Coordinated Time\n\
--help display this help and exit\n\
--version output version information and exit\n\
%%y last two digits of year (00..99)\n\
");
}
-
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... PATH\n", program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [STRING]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [STRING]...\n", program_name);
+ printf ("\
\n\
-n do not output the trailing newline\n\
-e (unused)\n\
\\t horizontal tab\n\
\\v vertical tab\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n",
+ program_name);
+ printf ("\
\n\
- -u, --unset NAME remove variable from the environment\n\
+ -u, --unset=NAME remove variable from the environment\n\
-i, --ignore-environment start with an empty environment\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
A mere - implies -i. If no COMMAND, print the resulting environment.\n\
");
-
+ }
exit (status);
}
#include "system.h"
#include "version.h"
-#include "long-option.h"
+#include "long-options.h"
#if !defined (isascii) || defined (STDC_HEADERS)
#undef isascii
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s EXPRESSION\n\
- or: %s OPTION\n\
-",
- program_name, program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
printf ("\
+Usage: %s EXPRESSION\n\
+ or: %s OPTION\n\
+",
+ program_name, program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\\( and \\) are not used, they return the number of characters matched or 0.\n\
");
}
-
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [USERNAME]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [USERNAME]\n", program_name);
+ printf ("\
\n\
-g, --group print only the group ID\n\
-n, --name print a name instead of a number, for -ugG\n\
\n\
Without any OPTION, print some useful set of identified information.\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]...\n", program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [COMMAND [ARG]...]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [COMMAND [ARG]...]\n", program_name);
+ printf ("\
\n\
-ADJUST increment priority by ADJUST first\n\
- -n, --adjustment ADJUST same as -ADJUST\n\
+ -n, --adjustment=ADJUST same as -ADJUST\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
With no COMMAND, print the current scheduling priority. ADJUST is 10\n\
by default. Range goes from -20 (highest priority) to 19 (lowest).\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... PATH...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... PATH...\n", program_name);
+ printf ("\
\n\
-p, --portability check for all POSIX systems, not only this one\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
#include "system.h"
#include "version.h"
-#include "long-option.h"
+#include "long-options.h"
#if !defined (isascii) || defined (STDC_HEADERS)
#undef isascii
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s FORMAT [ARGUMENT]...\n\
- or: %s OPTION\n\
-",
- program_name, program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("\
+Usage: %s FORMAT [ARGUMENT]...\n\
+ or: %s OPTION\n\
+",
+ program_name, program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
and all C format specifications ending with one of diouxXfeEgGcs, with\n\
ARGUMENTs converted to proper type first. Variable widths are handled.\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... NUMBER[SUFFIX]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... NUMBER[SUFFIX]\n", program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
SUFFIX may be s for seconds, m for minutes, h for hours or d for days.\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [SETTING]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
+ printf ("Usage: %s [OPTION]... [SETTING]...\n", program_name);
printf ("\
\n\
-a, --all print all current settings in human-readable form\n\
127; special values ^- or undef used to disable special characters.\n\
");
}
-
exit (status);
}
if (optind == argc)
{
if (optc == '?')
- error (1, 0, "invalid argument `%s'", argv[--optind]);
+ {
+ error (0, 0, "invalid argument `%s'", argv[--optind]);
+ usage (1);
+ }
display_settings (output_type, &mode);
exit (0);
}
}
}
if (match_found == 0 && reversed)
- error (1, 0, "invalid argument `%s'", --argv[optind]);
+ {
+ error (0, 0, "invalid argument `%s'", --argv[optind]);
+ usage (1);
+ }
if (match_found == 0)
{
for (i = 0; control_info[i].name != NULL; ++i)
if (!strcmp (argv[optind], control_info[i].name))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
match_found = 1;
++optind;
set_control_char (&control_info[i], argv[optind], &mode);
if (!strcmp (argv[optind], "ispeed"))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
++optind;
set_speed (input_speed, argv[optind], &mode);
}
else if (!strcmp (argv[optind], "ospeed"))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
++optind;
set_speed (output_speed, argv[optind], &mode);
}
else if (!strcmp (argv[optind], "rows"))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
++optind;
set_window_size ((int) integer_arg (argv[optind]), -1);
}
|| !strcmp (argv[optind], "columns"))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
++optind;
set_window_size (-1, (int) integer_arg (argv[optind]));
}
else if (!strcmp (argv[optind], "line"))
{
if (optind == argc - 1)
- error (1, 0, "missing argument to `%s'", argv[optind]);
+ {
+ error (0, 0, "missing argument to `%s'", argv[optind]);
+ usage (1);
+ }
++optind;
mode.c_line = integer_arg (argv[optind]);
}
else if (string_to_baud (argv[optind]) != (speed_t) -1)
set_speed (both_speeds, argv[optind], &mode);
else if (recover_mode (argv[optind], &mode) == 0)
- error (1, 0, "invalid argument `%s'", argv[optind]);
+ {
+ error (0, 0, "invalid argument `%s'", argv[optind]);
+ usage (1);
+ }
}
optind++;
}
p--;
if (*p)
- error (1, 0, "invalid integer argument `%s'", s);
+ {
+ error (0, 0, "invalid integer argument `%s'", s);
+ usage (1);
+ }
return value;
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [-] [USER [ARG]...]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [-] [USER [ARG]...]\n", program_name);
+ printf ("\
\n\
-l, --login make the shell a login shell\n\
- -c, --commmand COMMAND pass a single COMMAND to the shell with -c\n\
+ -c, --commmand=COMMAND pass a single COMMAND to the shell with -c\n\
-f, --fast pass -f to the shell (for csh or tcsh)\n\
-m, --preserve-environment do not reset environment variables\n\
-p same as -m\n\
- -s, --shell SHELL run SHELL if /etc/shells allows it\n\
+ -s, --shell=SHELL run SHELL if /etc/shells allows it\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
A mere - implies -l. If USER not given, assume root.\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [FILE]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
+ printf ("\
\n\
-a, --append append to the given FILEs, do not overwrite\n\
-i, --ignore-interrupts ignore interrupt signals\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
}
#if defined (TEST_STANDALONE)
-#include "long-option.h"
+#include "long-options.h"
static void
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s EXPRESSION\n\
- or: [ EXPRESSION ]\n\
- or: %s OPTION\n\
-",
- program_name, program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
printf ("\
+Usage: %s EXPRESSION\n\
+ or: [ EXPRESSION ]\n\
+ or: %s OPTION\n\
+",
+ program_name, program_name);
+ printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\
");
}
-
exit (status);
}
#endif /* TEST_STANDALONE */
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]...\n", program_name);
+ printf ("\
\n\
-s, --silent, --quiet print nothing, only return an exit status\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]...\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]...\n", program_name);
+ printf ("\
\n\
-a, --all print all information\n\
-m, --machine print the machine (hardware) type\n\
\n\
Without any OPTION, assume -s.\n\
");
-
+ }
exit (status);
}
usage (status)
int status;
{
- fprintf (status == 0 ? stdout : stderr, "\
-Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n\
-",
- program_name);
-
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
-
- printf ("\
+ {
+ printf ("Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n", program_name);
+ printf ("\
\n\
-H, --heading print line of column headings\n\
-T, -w, --mesg add user's message status as +, - or ?\n\
If FILE not given, uses /etc/utmp. /etc/wtmp as FILE is common.\n\
If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.\n\
");
-
+ }
exit (status);
}