| 38 | #include <unistd.h> |
| 39 | |
| 40 | int |
| 41 | main(int argc, char **argv) |
| 42 | { |
| 43 | int c; |
| 44 | int status = 0; |
| 45 | |
| 46 | optind = 2; /* Past the program name and the option letters. */ |
| 47 | while ((c = getopt(argc, argv, argv[1])) != -1) |
| 48 | switch (c) { |
| 49 | case '?': |
| 50 | status = 1; /* getopt routine gave message */ |
| 51 | break; |
| 52 | default: |
| 53 | if (optarg != NULL) |
| 54 | printf(" -%c %s", c, optarg); |
| 55 | else |
| 56 | printf(" -%c", c); |
| 57 | break; |
| 58 | } |
| 59 | printf(" --"); |
| 60 | for (; optind < argc; optind++) |
| 61 | printf(" %s", argv[optind]); |
| 62 | printf("\n"); |
| 63 | return(status); |
| 64 | } |