Commit 9814e6a376df853a88deb889d68f178c803ad8ca

Christian Weisgerber 2020-09-27T14:55:18

prefer the BSD extension to reset getopt over the GNU one Sadly there is no portable way to reset getopt(3). BSD: optind = 1; optreset = 1; GNU: optind = 0; ok stsp

diff --git a/got/got.c b/got/got.c
index d493fce..b8f662a 100644
--- a/got/got.c
+++ b/got/got.c
@@ -213,7 +213,8 @@ main(int argc, char *argv[])
 
 	argc -= optind;
 	argv += optind;
-	optind = 0;
+	optind = 1;
+	optreset = 1;
 
 	if (Vflag) {
 		got_version_print_str();
diff --git a/tog/tog.c b/tog/tog.c
index c85b72c..4d3c8ce 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -5652,7 +5652,7 @@ main(int argc, char *argv[])
 
 	argc -= optind;
 	argv += optind;
-	optind = 0;
+	optind = 1;
 	optreset = 1;
 
 	if (Vflag) {