1 /* $FreeBSD$ */ 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <unistd.h> 6 7 int 8 main(argc, argv) 9 int argc; 10 char *argv[]; 11 { 12 int c; 13 int status = 0; 14 15 optind = 2; /* Past the program name and the option letters. */ 16 while ((c = getopt(argc, argv, argv[1])) != -1) 17 switch (c) { 18 case '?': 19 status = 1; /* getopt routine gave message */ 20 break; 21 default: 22 if (optarg != NULL) 23 printf(" -%c %s", c, optarg); 24 else 25 printf(" -%c", c); 26 break; 27 } 28 printf(" --"); 29 for (; optind < argc; optind++) 30 printf(" %s", argv[optind]); 31 printf("\n"); 32 exit(status); 33 } 34