this extension is not incompatible with the standard behavior of the
function, not expensive, and avoids requiring a replacement getopt
with full GNU extensions for a few important apps including busybox's
sed with the -i option.
}
return '?';
}
- optarg = argv[optind++] + optpos;
- optpos = 0;
+ if (optstring[i+2] == ':') optarg = 0;
+ if (optstring[i+2] != ':' || optpos) {
+ optarg = argv[optind++] + optpos;
+ optpos = 0;
+ }
}
return c;
}