Commit 1a7b6c03 authored by Niels Möller's avatar Niels Möller

Send usage message to stderr, rather than stdout, on errors.

parent 90b82481
2012-07-10 Niels Möller <nisse@lysator.liu.se> 2012-07-10 Niels Möller <nisse@lysator.liu.se>
* src/testsuite/mini-inetd.c (usage): Take a FILE * as argument.
Called with stdout in response to --help, and stderr otherwise.
* src/testsuite/prgrp-timeout.c: Added missing include of * src/testsuite/prgrp-timeout.c: Added missing include of
config.h. config.h.
......
...@@ -63,13 +63,19 @@ werror(const char *format, ...) ...@@ -63,13 +63,19 @@ werror(const char *format, ...)
} }
static void static void
usage (void) usage (FILE *f)
{ {
printf("mini-inetd [OPTIONS] [localaddr:]port program [argv0, argv1 ...]\n" fprintf(f,
"Options:\n" /* FIXME: ':' is a bad separator for literal IPv6 addresses.
" -m max-connections\n" Support [] around the address? */
" --help\n" "mini-inetd [OPTIONS] [localaddr:]port program [argv0, argv1 ...]\n"
" --background\n"); "Options:\n"
" -m max-connections\n"
" --help\n"
" --background\n"
" -4 Only use IPv4.\n"
" -6 Only use IPv6.\n"
" --help Display this help.\n");
} }
static void static void
...@@ -133,7 +139,7 @@ main (int argc, char **argv) ...@@ -133,7 +139,7 @@ main (int argc, char **argv)
case '?': case '?':
return EXIT_FAILURE; return EXIT_FAILURE;
case OPT_HELP: case OPT_HELP:
usage(); usage(stdout);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case OPT_BACKGROUND: case OPT_BACKGROUND:
background = 1; background = 1;
...@@ -164,7 +170,7 @@ main (int argc, char **argv) ...@@ -164,7 +170,7 @@ main (int argc, char **argv)
if (argc < 2) if (argc < 2)
{ {
usage(); usage(stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
sep = strrchr(argv[0], ':'); sep = strrchr(argv[0], ':');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment