I'd like to call getopt with one set of arguments, and once that's
completely done call it again with an entirely different set of
arguments. I've found though that at least with the getopt
implementation common to both glibc and newlib, getopt has to be
"cleaned up" in between. The glibc source code shows that to clean it
up either optind must be set to zero or __getopt_initialized must be
set to non-zero. The latter is clearly non-standard, is the former
possibly more standard? It seems to me this issue must have been
encountered and addressed sometime before.
I ran into a bug with busybox because it set optind to 1 to clean up
getopt, but this was insufficient with newlib (and glibc) and was
causing errors when parsing options.
Thanks,
Shaun