]>
Commit | Line | Data |
---|---|---|
44bd5ea7 | 1 | #include <sys/cdefs.h> |
9bafe280 | 2 | __RCSID("$FreeBSD: src/usr.bin/getopt/getopt.c,v 1.10 2002/09/04 23:29:01 dwmalone Exp $"); |
44bd5ea7 | 3 | |
44bd5ea7 | 4 | #include <stdio.h> |
c0fcf4e1 | 5 | #include <stdlib.h> |
9bafe280 | 6 | #include <unistd.h> |
44bd5ea7 A |
7 | |
8 | int | |
9bafe280 | 9 | main(int argc, char *argv[]) |
44bd5ea7 A |
10 | { |
11 | int c; | |
12 | int status = 0; | |
13 | ||
14 | optind = 2; /* Past the program name and the option letters. */ | |
15 | while ((c = getopt(argc, argv, argv[1])) != -1) | |
16 | switch (c) { | |
17 | case '?': | |
18 | status = 1; /* getopt routine gave message */ | |
19 | break; | |
20 | default: | |
21 | if (optarg != NULL) | |
22 | printf(" -%c %s", c, optarg); | |
23 | else | |
24 | printf(" -%c", c); | |
25 | break; | |
26 | } | |
27 | printf(" --"); | |
28 | for (; optind < argc; optind++) | |
29 | printf(" %s", argv[optind]); | |
30 | printf("\n"); | |
9bafe280 | 31 | return status; |
44bd5ea7 | 32 | } |