Simplify markup.
[netbsd-mini2440.git] / usr.bin / getopt / getopt.c
blob9a47fa0faf1908ae341a204eb71d83955b3824fa
1 /* $NetBSD: getopt.c,v 1.7 2006/07/09 21:38:47 wiz Exp $ */
3 /*
4 * This material, written by Henry Spencer, was released by him
5 * into the public domain and is thus not subject to any copyright.
6 */
8 #include <sys/cdefs.h>
9 #ifndef lint
10 __RCSID("$NetBSD: getopt.c,v 1.7 2006/07/09 21:38:47 wiz Exp $");
11 #endif /* not lint */
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <unistd.h>
17 int
18 main(int argc, char *argv[])
20 int c;
21 int status = 0;
23 optind = 2; /* Past the program name and the option letters. */
24 while ((c = getopt(argc, argv, argv[1])) != -1)
25 switch (c) {
26 case '?':
27 status = 1; /* getopt routine gave message */
28 break;
29 default:
30 if (optarg != NULL)
31 printf(" -%c %s", c, optarg);
32 else
33 printf(" -%c", c);
34 break;
36 printf(" --");
37 for (; optind < argc; optind++)
38 printf(" %s", argv[optind]);
39 printf("\n");
40 exit(status);