Jan Stary <h...@stare.cz> writes: > Some programs in bin/ and usr.bin/ use the following idiom > to make sure that there are no options present: > > while ((ch = getopt(argc, argv, "")) != -1) > switch (ch) { > case '?': > default: > usage(); > /* NOTREACHED */ > } > > if (argc != optind) { > usage(); > /* NOTREACHED */ > } > > Why is this better then simply checking that (argc == 1)?
getopt(3) handles --. Using getopt(3) everywhere is good for consistency. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE