/[public]/getopt/trunk/getopt.c
ViewVC logotype

Diff of /getopt/trunk/getopt.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 361 Revision 363
63#include <getopt.h> 63#include <getopt.h>
64#else 64#else
65#include "getopt.h" 65#include "getopt.h"
66#endif 66#endif
67 67
68#include "util-linux-compat.h"
68#include "nls.h" 69#include "nls.h"
69#include "xalloc.h" 70#include "xalloc.h"
70 71
71/* NON_OPT is the code that is returned when a non-option is found in '+' 72/* NON_OPT is the code that is returned when a non-option is found in '+'
72 * mode */ 73 * mode */
318 ("unknown shell after -s or --shell argument")); 319 ("unknown shell after -s or --shell argument"));
319} 320}
320 321
321static void __attribute__ ((__noreturn__)) print_help(void) 322static void __attribute__ ((__noreturn__)) print_help(void)
322{ 323{
323 fputs(_("Usage: getopt optstring parameters\n"), stderr); 324 fputs(USAGE_HEADER, stderr);
324 fputs(_(" getopt [options] [--] optstring parameters\n"), stderr); 325 fprintf(stderr, _(
325 fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"), stderr); 326 " %1$s optstring parameters\n"
326 fputs(_(" parameters\n"), stderr); 327 " %1$s [options] [--] optstring parameters\n"
327 fputs(_("\nOptions:\n"), stderr); 328 " %1$s [options] -o|--options optstring [options] [--] parameters\n"),
329 program_invocation_short_name);
330
331 fputs(USAGE_OPTIONS, stderr);
328 fputs(_(" -a, --alternative Allow long options starting with single -\n"), stderr); 332 fputs(_(" -a, --alternative Allow long options starting with single -\n"), stderr);
329 fputs(_(" -h, --help This small usage guide\n"), stderr);
330 fputs(_(" -l, --longoptions <longopts> Long options to be recognized\n"), stderr); 333 fputs(_(" -l, --longoptions <longopts> Long options to be recognized\n"), stderr);
331 fputs(_(" -n, --name <progname> The name under which errors are reported\n"), stderr); 334 fputs(_(" -n, --name <progname> The name under which errors are reported\n"), stderr);
332 fputs(_(" -o, --options <optstring> Short options to be recognized\n"), stderr); 335 fputs(_(" -o, --options <optstring> Short options to be recognized\n"), stderr);
333 fputs(_(" -q, --quiet Disable error reporting by getopt(3)\n"), stderr); 336 fputs(_(" -q, --quiet Disable error reporting by getopt(3)\n"), stderr);
334 fputs(_(" -Q, --quiet-output No normal output\n"), stderr); 337 fputs(_(" -Q, --quiet-output No normal output\n"), stderr);
335 fputs(_(" -s, --shell <shell> Set shell quoting conventions\n"), stderr); 338 fputs(_(" -s, --shell <shell> Set shell quoting conventions\n"), stderr);
336 fputs(_(" -T, --test Test for getopt(1) version\n"), stderr); 339 fputs(_(" -T, --test Test for getopt(1) version\n"), stderr);
337 fputs(_(" -u, --unquote Do not quote the output\n"), stderr); 340 fputs(_(" -u, --unquoted Do not quote the output\n"), stderr);
338 fputs(_(" -V, --version Output version information\n"), stderr); 341 fputs(USAGE_SEPARATOR, stderr);
339 fputc('\n', stderr); 342 fputs(USAGE_HELP, stderr);
340 343 fputs(USAGE_VERSION, stderr);
344 fprintf(stderr, USAGE_MAN_TAIL("getopt(1)"));
341 exit(PARAMETER_EXIT_CODE); 345 exit(PARAMETER_EXIT_CODE);
342} 346}
343 347
344int main(int argc, char *argv[]) 348int main(int argc, char *argv[])
345{ 349{
430 return TEST_EXIT_CODE; 434 return TEST_EXIT_CODE;
431 case 'u': 435 case 'u':
432 quote = 0; 436 quote = 0;
433 break; 437 break;
434 case 'V': 438 case 'V':
435 printf(_("%s (enhanced) %s\n"), program_invocation_short_name, program_version); 439 printf(UTIL_LINUX_VERSION);
436 return EXIT_SUCCESS; 440 return EXIT_SUCCESS;
437 case '?': 441 case '?':
438 case ':': 442 case ':':
439 parse_error(NULL); 443 parse_error(NULL);
440 default: 444 default:

Legend:
Removed from v.361  
changed lines
  Added in v.363

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26