View Single Post
  #4   (View Single Post)  
Old 26th March 2013
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by bsdplus View Post
with getopt, I thought all arguments passed on on command line have to be processed by it and it would be treated as error if more arguments are passed than it would expect.
getopt(3) will only process what it is instructed to interpret.

Recognize that the example I provided is limited in the way that optind was used. Here, all command-line parameters understood by getopt(3) had to be provided first. This is not a limitation by getopt(3) itself; it is merely a limitation imposed by how optind was being used to distinguish which parameters were not processed by getopt(3). A more complicated scheme could be implemented which would allow any kind of ordering, but that would be more involved than a twenty line example.
Reply With Quote