> On Oct 12 15:00:23, j...@wxcvbn.org wrote:
> > 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.
> 
> I don't get it: why do we need to handle --
> in utils which take no options and no arguments?
> 
> e.g. logname(1) is supposed to be launched just like "logname".
> Does logname.c do the above just to handle "logname --" ?

Because POSIX says so.  Look Jan, if you are going to start touching
POSIX utilities you need to read the standards.

Reply via email to