1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-12 06:57:33 +02:00

merge with 1.8.1g

This commit is contained in:
Jim Meyering
1993-10-17 03:57:04 +00:00
parent 6e1a4cca68
commit fa7a1e19e2
20 changed files with 800 additions and 122 deletions

View File

@@ -1,3 +1,24 @@
Sat Oct 16 22:32:54 1993 Jim Meyering (meyering@comco.com)
* whoami.c (main): Cast printf arg UID so it matches the type
expected by %u format no matter how uid_t is defined.
* stty.c: Accept `status' option and VDISCARD as an alias for
VFLUSHO. From Arne H. Juul (arnej@imf.unit.no).
* basename.c, date.c, dirname.c, echo.c, env.c, expr.c,
false.sh, groups.sh, id.c, logname.c, long-options.c, nice.c,
nohup.sh, pathchk.c, printenv.c, printf.c, sleep.c, stty.c,
su.c, tee.c, test.c, true.sh, tty.c, uname.c, who.c, whoami.c,
yes.c: Using --help gets long well- formatted help. Now --help
writes to stdout and exits successfully. From Francois Pinard
<pinard@iro.umontreal.ca>.
Wed Oct 13 13:10:27 1993 Jim Meyering (meyering@comco.com)
* long-options.c: Include sys/types before system.h.
From Franc,ois Pinard (pinard@iro.umontreal.ca).
Tue Oct 12 00:53:26 1993 Jim Meyering (meyering@comco.com)
* stime.c [HAVE_CONFIG_H, CONFIG_BROKETS]: Include <config.h>

View File

@@ -65,11 +65,26 @@ static struct option const long_options[] =
};
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] name [suffix]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... PATH [SUFFIX]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
exit (status);
}
void
@@ -90,7 +105,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -101,10 +116,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (argc - optind == 0 || argc - optind > 2)
usage ();
usage (1);
strip_trailing_slashes (argv[optind]);

View File

@@ -140,7 +140,7 @@ main (argc, argv)
universal_time = 1;
break;
default:
usage ();
usage (1);
}
if (show_version)
@@ -150,10 +150,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (argc - optind > 1)
usage ();
usage (1);
if (universal_time && putenv (TZ_UCT) != 0)
error (1, 0, "virtual memory exhausted");
@@ -221,12 +221,63 @@ show_date (format, when)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [{--help,--version}] [-u] [-d datestr] [-s datestr]\n\
[--date datestr] [--set datestr] [--uct] [--universal]\n\
[+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
{
printf ("\
\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\
");
printf ("\
\n\
FORMAT controls the output. Interpreted sequences are:\n\
\n\
%%%% a literal %%\n\
%%A locale's full weekday name, variable length (Sunday..Saturday)\n\
%%B locale's full month name, variable length (January..December)\n\
%%D date (mm/dd/yy)\n\
%%H hour (00..23)\n\
%%I hour (01..12)\n\
%%M minute (00..59)\n\
%%S second (00..61)\n\
%%T time, 24-hour (hh:mm:ss)\n\
%%U week number of year with Sunday as first day of week (00..53)\n\
%%W week number of year with Monday as first day of week (00..53)\n\
%%X locale's time representation (%%H:%%M:%%S)\n\
%%Y year (1970...)\n\
%%Z time zone (e.g., EDT), or nothing if no time zone is determinable\n\
%%a locale's abbreviated weekday name (Sun..Sat)\n\
%%b locale's abbreviated month name (Jan..Dec)\n\
%%c locale's date and time (Sat Nov 04 12:02:33 EST 1989)\n\
%%d day of month (01..31)\n\
%%h same as %%b\n\
%%j day of year (001..366)\n\
%%k hour ( 0..23)\n\
%%l hour ( 1..12)\n\
%%m month (01..12)\n\
%%n a newline\n\
%%p locale's AM or PM\n\
%%r time, 12-hour (hh:mm:ss [AP]M)\n\
%%t a horizontal tab\n\
%%w day of week (0..6)\n\
%%x locale's date representation (mm/dd/yy)\n\
%%y last two digits of year (00..99)\n\
");
}
exit (status);
}

View File

@@ -54,10 +54,26 @@ static struct option const long_options[] =
};
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] path\n", program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... PATH\n\
",
program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
exit (status);
}
void
@@ -79,7 +95,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -90,10 +106,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (argc - optind != 1)
usage ();
usage (1);
path = argv[optind];
strip_trailing_slashes (path);

View File

@@ -74,11 +74,42 @@ char *program_name;
void parse_long_options ();
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] [-ne] [string ...]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [STRING]...\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-n do not output the trailing newline\n\
-e (unused)\n\
-E disable interpolation of some sequences in STRINGs\n\
--help display this help and exit (should be alone)\n\
--version output version information and exit (should be alone)\n\
\n\
Without -E, the following sequences are recognized and interpolated:\n\
\n\
\\NNN the character whose ASCII code is NNN (octal)\n\
\\\\ backslash\n\
\\a alert (BEL)\n\
\\b backspace\n\
\\c suppress trailing newline\n\
\\f form feed\n\
\\n new line\n\
\\r carriage return\n\
\\t horizontal tab\n\
\\v vertical tab\n\
");
exit (status);
}
/* Print the words in LIST to standard output. If the first word is

View File

@@ -145,7 +145,7 @@ main (argc, argv, envp)
case 'u':
break;
default:
usage ();
usage (2);
}
}
@@ -156,7 +156,7 @@ main (argc, argv, envp)
}
if (show_help)
usage ();
usage (0);
if (optind != argc && !strcmp (argv[optind], "-"))
ignore_environment = 1;
@@ -192,11 +192,28 @@ main (argc, argv, envp)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [{--help,--version}] [-] [-i] [-u name] [--ignore-environment]\n\
[--unset=name] [name=value]... [command [args...]]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n\
",
program_name);
exit (2);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\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);
}

View File

@@ -111,11 +111,62 @@ static void trace ();
#endif
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] expression...\n",
program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s EXPRESSION\n\
or: %s OPTION\n\
",
program_name, program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
{
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
");
printf ("\
EXPRESSION value is written on standard output. A white line\n\
separates increasing precedence groups. EXPRESSION may be:\n\
\n\
ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2\n\
\n\
ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0\n\
\n\
ARG1 < ARG2 ARG1 is less than ARG2\n\
ARG1 <= ARG2 ARG1 is less than or equal to ARG2\n\
ARG1 = ARG2 ARG1 is equal to ARG2\n\
ARG1 != ARG2 ARG1 is unequal to ARG2\n\
ARG1 >= ARG2 ARG1 is greater than or equal to ARG2\n\
ARG1 > ARG2 ARG1 is greater than ARG2\n\
\n\
ARG1 + ARG2 arithmetic sum of ARG1 and ARG2\n\
ARG1 - ARG2 arithmetic difference of ARG1 and ARG2\n\
\n\
ARG1 * ARG2 arithmetic product of ARG1 and ARG2\n\
ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2\n\
ARG1 %% ARG2 arithmetic remainder of ARG1 divided by ARG2\n\
\n\
STRING : REGEXP anchored pattern match of REGEXP in STRING\n\
\n\
( EXPRESSION ) value of EXPRESSION\n\
");
printf ("\
\n\
Beware that some operators need to be escaped by backslashes for shells.\n\
Comparisons are arithmetic if both ARGs are numbers, else lexicographical.\n\
Pattern matches return the string matched between \\( and \\) or null; if\n\
\\( and \\) are not used, they return the number of characters matched or 0.\n\
");
}
exit (status);
}
void
@@ -130,7 +181,7 @@ main (argc, argv)
parse_long_options (argc, argv, usage);
if (argc == 1)
usage ();
usage (1);
args = argv + 1;
v = eval ();

View File

@@ -143,7 +143,7 @@ main (argc, argv)
just_group_list = 1;
break;
default:
usage ();
usage (1);
}
}
@@ -154,7 +154,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (just_user + just_group + just_group_list > 1)
error (1, 0, "cannot print only user and only group");
@@ -163,7 +163,7 @@ main (argc, argv)
error (1, 0, "cannot print only names or real IDs in default format");
if (argc - optind > 1)
usage ();
usage (1);
if (argc - optind == 1)
{
@@ -360,10 +360,31 @@ print_full_info (username)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-gnruG] [--group] [--name] [--real] [--user] [--groups] [username]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [USERNAME]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-g, --group print only the group ID\n\
-n, --name print a name instead of a number, for -ugG\n\
-r, --real print the real ID instead of effective ID, for -ugG\n\
-u, --user print only the user ID\n\
-G, --groups print only the supplementary groups\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
Without any OPTION, print some useful set of identified information.\n\
");
exit (status);
}

View File

@@ -50,11 +50,26 @@ static struct option const long_options[] =
};
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]...\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
");
exit (status);
}
void
@@ -75,7 +90,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -86,10 +101,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (argc - optind != 0)
usage ();
usage (1);
/* POSIX.2 requires using getlogin (or equivalent code). */
cp = getlogin ();

View File

@@ -86,7 +86,7 @@ main (argc, argv)
switch (optc)
{
case '?':
usage ();
usage (1);
case 0:
break;
@@ -115,7 +115,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (minusflag)
adjustment = -adjustment;
@@ -125,7 +125,7 @@ main (argc, argv)
if (optind == argc)
{
if (adjustment_given)
usage ();
usage (1);
/* No command given; print the priority. */
errno = 0;
current_priority = GET_PRIORITY ();
@@ -171,11 +171,29 @@ isinteger (s)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-n adjustment] [-adjustment] [--adjustment=adjustment]\n\
[command [arg...]]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [COMMAND [ARG]...]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-ADJUST increment priority by ADJUST first\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);
}

View File

@@ -146,7 +146,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -157,10 +157,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (optind == argc)
usage ();
usage (1);
for (; optind < argc; ++optind)
exit_status |= validate_path (argv[optind], check_portability);
@@ -358,10 +358,25 @@ validate_path (path, portability)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-p] [--portability] path...\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... PATH...\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
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);
}

View File

@@ -101,11 +101,48 @@ static int exit_status;
char *program_name;
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] format [argument...]\n",
program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s FORMAT [ARGUMENT]...\n\
or: %s OPTION\n\
",
program_name, program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
FORMAT controls the output as in C printf. Interpreted sequences are:\n\
\n\
\\\" double quote\n\
\\0NNN character with octal value NNN (0 to 3 digits)\n\
\\\\ backslash\n\
\\a alert (BEL)\n\
\\b backspace\n\
\\c produce no further output\n\
\\f form feed\n\
\\n new line\n\
\\r carriage return\n\
\\t horizontal tab\n\
\\v vertical tab\n\
\\xNNN character with hexadecimal value NNN (1 to 3 digits)\n\
\n\
%%%% a single %%\n\
%%b ARGUMENT as a string with `\\' escapes interpreted\n\
\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);
}
void

View File

@@ -54,11 +54,28 @@ static struct option const long_options[] =
};
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] number[smhd]...\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... NUMBER[SUFFIX]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
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);
}
void
@@ -80,7 +97,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -91,7 +108,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (argc == 1)
{

View File

@@ -119,7 +119,13 @@
#define CLNEXT Control ('v')
#endif
#if defined(VFLUSHO) && !defined(CFLUSHO)
#define CFLUSHO Control ('o')
#define CFLUSHO Control ('o')
#endif
#if defined(VDISCARD) && !defined(VFLUSHO)
#define VFLUSHO VDISCARD
#endif
#if defined(VSTATUS) && !defined(CSTATUS)
#define CSTATUS Control ('t')
#endif
char *visible ();
@@ -365,6 +371,10 @@ static struct control_info control_info[] =
#ifdef VFLUSHO
{"flush", CFLUSHO, VFLUSHO},
#endif
#ifdef VSTATUS
{"status", CSTATUS, VSTATUS},
#endif
/* These must be last because of the display routines. */
{"min", 1, VMIN},
@@ -433,12 +443,184 @@ wrapf (message, va_alist)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr,
"Usage: %s [{--help,--version}] [-ag] [--all] [--save] [setting...]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [SETTING]...\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
{
printf ("\
\n\
-a, --all print all current settings in human-readable form\n\
-g, --save print all current settings in a stty-readable form\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
Optionnal - before SETTING indicates negation. An * marks non-POSIX\n\
settings. The underlying system defines which settings are available.\n\
");
printf ("\
\n\
Special characters:\n\
* dsusp CHAR CHAR will send a terminal stop signal once input flushed\n\
eof CHAR CHAR will send an end of file (terminate the input)\n\
eol CHAR CHAR will end the line\n\
* eol2 CHAR alternate CHAR for ending the line\n\
erase CHAR CHAR will erase the last character typed\n\
intr CHAR CHAR will send an interrupt signal\n\
kill CHAR CHAR will erase the current line\n\
* lnext CHAR CHAR will enter the next character quoted\n\
quit CHAR CHAR will send a quit signal\n\
* rprnt CHAR CHAR will redraw the current line\n\
start CHAR CHAR will restart the output after stopping it\n\
stop CHAR CHAR will stop the output\n\
susp CHAR CHAR will send a terminal stop signal\n\
* swtch CHAR CHAR will switch to a different shell layer\n\
* werase CHAR CHAR will erase the last word typed\n\
");
printf ("\
\n\
Special settings:\n\
N set the input and output speeds to N bauds\n\
* cols N tell the kernel that the terminal has N columns\n\
* columns N same as cols N\n\
ispeed N set the input speed to N\n\
* line N use line discipline N\n\
min N with -icanon, set N characters minimum for a completed read\n\
ospeed N set the output speed to N\n\
* rows N tell the kernel that the terminal has N rows\n\
* size print the number of rows and columns according to the kernel\n\
speed print the terminal speed\n\
time N with -icanon, set read timeout of N tenths of a second\n\
");
printf ("\
\n\
Control settings:\n\
[-]clocal disable modem control signals\n\
[-]cread allow input to be received\n\
* [-]crtscts enable RTS/CTS handshaking\n\
csN set character size to N bits, N in [5..8]\n\
[-]cstopb use two stop bits per character (one with `-')\n\
[-]hup send a hangup signal when the last process closes the tty\n\
[-]hupcl same as [-]hup\n\
[-]parenb generate parity bit in output and expect parity bit in input\n\
[-]parodd set odd parity (even with `-')\n\
");
printf ("\
\n\
Input settings:\n\
[-]brkint breaks cause an interrupt signal\n\
[-]icrnl translate carriage return to newline\n\
[-]ignbrk ignore breaks\n\
[-]igncr ignore carriage return\n\
[-]ignpar ignore parity errors\n\
* [-]imaxbel beep and do not flush a full input buffer on a character\n\
[-]inlcr translate newline to carriage return\n\
[-]inpck enable input parity checking\n\
[-]istrip clear high (8th) bit of input characters\n\
* [-]iuclc translate uppercase characters to lowercase\n\
* [-]ixany let any character restart output, not only start character\n\
[-]ixoff enable sending of start/stop characters\n\
[-]ixon enable XON/XOFF flow control\n\
[-]parmrk mark parity errors (with a 255-0-character sequence)\n\
[-]tandem same as [-]ixoff\n\
");
printf ("\
\n\
Output settings:\n\
* bsN backspace delay style, N in [0..1]\n\
* crN carriage return delay style, N in [0..3]\n\
* ffN form feed delay style, N in [0..1]\n\
* nlN newline delay style, N in [0..1]\n\
* [-]ocrnl translate carriage return to newline\n\
* [-]ofdel use delete characters for fill instead of null characters\n\
* [-]ofill use fill (padding) characters instead of timing for delays\n\
* [-]olcuc translate lowercase characters to uppercase\n\
* [-]onlcr translate newline to carriage return-newline\n\
* [-]onlret newline performs a carriage return\n\
* [-]onocr do not print carriage returns in the first column\n\
[-]opost postprocess output\n\
* tabN horizontal tab delay style, N in [0..3]\n\
* tabs same as tab0\n\
* -tabs same as tab3\n\
* vtN vertical tab delay style, N in [0..1]\n\
");
printf ("\
\n\
Local settings:\n\
[-]crterase echo erase characters as backspace-space-backspace\n\
* crtkill kill all line by obeying the echoprt and echoe settings\n\
* -crtkill kill all line by obeying the echoctl and echok settings\n\
* [-]ctlecho echo control characters in hat notation (`^c')\n\
[-]echo echo input characters\n\
* [-]echoctl same as [-]ctlecho\n\
[-]echoe same as [-]crterase\n\
[-]echok echo a newline after a kill character\n\
* [-]echoke same as [-]crtkill\n\
[-]echonl echo newline even if not echoing other characters\n\
* [-]echoprt echo erased characters backward, between `\\' and '/'\n\
[-]icanon enable erase, kill, werase, and rprnt special characters\n\
[-]iexten enable non-POSIX special characters\n\
[-]isig enable interrupt, quit, and suspend special characters\n\
[-]noflsh disable flushing after interrupt and quit special characters\n\
* [-]prterase same as [-]echoprt\n\
* [-]tostop stop background jobs that try to write to the terminal\n\
* [-]xcase with icanon, escape with `\\' for uppercase characters\n\
");
printf ("\
\n\
Combination settings:\n\
* [-]LCASE same as [-]lcase\n\
cbreak same as -icanon\n\
-cbreak same as icanon\n\
cooked same as brkint ignpar istrip icrnl ixon opost isig\n\
icanon, eof and eol characters to their default values\n\
-cooked same as raw\n\
crt same as echoe echoctl echoke\n\
dec same as echoe echoctl echoke -ixany intr ^c erase 0177\n\
kill ^u\n\
* [-]decctlq same as [-]ixany\n\
ek erase and kill characters to their default values\n\
evenp same as parenb -parodd cs7\n\
-evenp same as -parenb cs8\n\
* [-]lcase same as xcase iuclc olcuc\n\
litout same as -parenb -istrip -opost cs8\n\
-litout same as parenb istrip opost cs7\n\
nl same as -icrnl -onlcr\n\
-nl same as icrnl -inlcr -igncr onlcr -ocrnl -onlret\n\
oddp same as parenb parodd cs7\n\
-oddp same as -parenb cs8\n\
[-]parity same as [-]evenp\n\
pass8 same as -parenb -istrip cs8\n\
-pass8 same as parenb istrip cs7\n\
raw same as -ignbrk -brkint -ignpar -parmrk -inpck -istrip\n\
-inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany\n\
-imaxbel -opost -isig -icanon -xcase min 1 time 0\n\
-raw same as cooked\n\
sane same as cread -ignbrk brkint -inlcr -igncr icrnl\n\
-ixoff -iucl -ixany imaxbel opost -olcuc -ocrnl onlcr\n\
-onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0\n\
isig icanon iexten echo echoe echok -echonl -noflsh\n\
-xcase -tostop -echoprt echoctl echoke, all special\n\
characters to their default values.\n\
");
printf ("\
\n\
Handle the tty line connected to standard input. Without arguments,\n\
prints baud rate, line discipline, and deviations from stty sane. In\n\
settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\
127; special values ^- or undef used to disable special characters.\n\
");
}
exit (status);
}
void
@@ -482,7 +664,7 @@ done:;
}
if (show_help)
usage ();
usage (0);
if (tcgetattr (0, &mode))
error (1, errno, "standard input");

View File

@@ -241,7 +241,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -252,7 +252,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (optind < argc && !strcmp (argv[optind], "-"))
{
@@ -548,11 +548,32 @@ concat (s1, s2, s3)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-flmp] [-c command] [-s shell] [--login] [--fast]\n\
[--preserve-environment] [--command=command] [--shell=shell] [-]\n\
[user [arg...]]\n", program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [-] [USER [ARG]...]\n\
",
program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-l, --login make the shell a login shell\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\
--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);
}

View File

@@ -67,13 +67,28 @@ static struct option const long_options[] =
};
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [{--help,--version}] [-ai] [--append]\n\
[--ignore-interrupts] [file...]\n",
program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [FILE]...\n\
",
program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
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);
}
void
@@ -105,7 +120,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -116,7 +131,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (ignore_interrupts)
{

View File

@@ -1011,11 +1011,84 @@ posixtest ()
void parse_long_options ();
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "Usage: %s [{--help,--version}] [expr]\n",
program_name);
exit (1);
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, "\nTry `%s --help' for more information.\n",
program_name);
else
{
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
EXPRESSION is true or false and sets exit status. It is one of:\n\
");
printf ("\
\n\
( EXPRESSION ) EXPRESSION is true\n\
! EXPRESSION EXPRESSION is false\n\
EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true\n\
EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true\n\
\n\
[-n] STRING the length of STRING is non-zero\n\
-z STRING the length of STRING is zero\n\
STRING1 = STRING2 the strings are equal\n\
STRING1 != STRING2 the strings are not equal\n\
\n\
INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2\n\
INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to INTEGER2\n\
INTEGER1 -gt INTEGER2 INTEGER1 is greater than INTEGER2\n\
INTEGER1 -le INTEGER2 INTEGER1 is less than or equal to INTEGER2\n\
INTEGER1 -lt INTEGER2 INTEGER1 is less than INTEGER2\n\
INTEGER1 -ne INTEGER2 INTEGER1 is not equal to INTEGER2\n\
");
printf ("\
\n\
FILE1 -ef FILE2 FILE1 and FILE2 have the same device and inode numbers\n\
FILE1 -nt FILE2 FILE1 is newer (modification date) than FILE2\n\
FILE1 -ot FILE2 FILE1 is older than FILE2\n\
\n\
-G FILE FILE exists and is owned by the effective group ID\n\
-L FILE FILE exists and is a symbolic link\n\
-O FILE FILE exists and is owned by the effective user ID\n\
-S FILE FILE exists and is a socket\n\
-b FILE FILE exists and is block special\n\
-c FILE FILE exists and is character special\n\
-d FILE FILE exists and is a directory\n\
-e FILE FILE exists\n\
-f FILE FILE exists and is a regular file\n\
-g FILE FILE exists and is set-group-ID\n\
-k FILE FILE exists and has its sticky bit set\n\
-p FILE FILE exists and is a named pipe\n\
-r FILE FILE exists and is readable\n\
-s FILE FILE exists and has a size greater than zero\n\
-t standard output is opened on a terminal\n\
-t FD file descriptor FD is opened on a terminal\n\
-u FILE FILE exists and its set-user-ID bit is set\n\
-w FILE FILE exists and is writable\n\
-x FILE FILE exists and is executable\n\
");
printf ("\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
Beware that parentheses need to be escaped by backslashes for shells.\n\
INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\
");
}
exit (status);
}
#endif /* TEST_STANDALONE */

View File

@@ -88,7 +88,7 @@ main (argc, argv)
break;
default:
usage ();
usage (2);
}
}
@@ -99,10 +99,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (optind != argc)
usage ();
usage (2);
tty = ttyname (0);
if (!silent)
@@ -120,9 +120,25 @@ main (argc, argv)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-s] [--silent] [--quiet]\n", program_name);
exit (2);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]...\n\
",
program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
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);
}

View File

@@ -137,7 +137,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -148,10 +148,10 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (optind != argc)
usage ();
usage (1);
if (toprint == 0)
toprint = PRINT_SYSNAME;
@@ -185,10 +185,32 @@ print_element (mask, element)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-snrvma] [--sysname] [--nodename] [--release] [--version]\n\
[--machine] [--all]\n", program_name);
exit (1);
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]...\n\
",
program_name);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-a, --all print all information\n\
-m, --machine print the machine (hardware) type\n\
-n, --nodename print the machine's network node hostname\n\
-r, --release print the operating system release\n\
-s, --sysname print the operating system name\n\
-v print the operating system version\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
Without any OPTION, assume -s.\n\
");
exit (status);
}

View File

@@ -168,7 +168,7 @@ main (argc, argv)
break;
default:
usage ();
usage (1);
}
}
@@ -179,7 +179,7 @@ main (argc, argv)
}
if (show_help)
usage ();
usage (0);
if (chdir ("/dev"))
error (1, errno, "cannot change directory to /dev");
@@ -205,7 +205,7 @@ main (argc, argv)
break;
default: /* lose */
usage ();
usage (1);
}
exit (0);
@@ -459,11 +459,35 @@ idle_string (when)
}
static void
usage ()
usage (status)
int status;
{
fprintf (stderr, "\
Usage: %s [-imqsuwHT] [--count] [--idle] [--heading] [--message] [--mesg]\n\
[--writable] [file] [am i]\n",
fprintf (status == 0 ? stdout : stderr, "\
Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n\
",
program_name);
exit (1);
if (status != 0)
fprintf (stderr, "\nTry `%s --help' for more information.\n",
program_name);
else
printf ("\
\n\
-H, --heading print line of column headings\n\
-T, -w, --mesg add user's message status as +, - or ?\n\
-i, -u, --idle add user idle time as HOURS:MINUTES, . or old\n\
-m only hostname and user associated with stdin\n\
-q, --count all login names and number of users logged on\n\
-s (ignored)\n\
--help display this help and exit\n\
--message same as -T\n\
--version output version information and exit\n\
--writeable same as -T\n\
\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);
}