As Larry pointed out, this the off by one canbe fixed much more elegantly.
diff --git a/chgrp.c b/chgrp.c
index 83bb194..55e22f5 100644
--- a/chgrp.c
+++ b/chgrp.c
@@ -71,7 +71,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
diff --git a/chmod.c b/chmod.c
index f22e5d0..b1d7512 100644
--- a/chmod.c
+++ b/chmod.c
@@ -66,7 +66,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
diff --git a/chown.c b/chown.c
index 43d62b1..e714b2d 100644
--- a/chown.c
+++ b/chown.c
@@ -85,7 +85,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c
index 83bb194..55e22f5 100644
--- a/coreutils/chgrp.c
+++ b/coreutils/chgrp.c
@@ -71,7 +71,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index f22e5d0..b1d7512 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -66,7 +66,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
diff --git a/coreutils/chown.c b/coreutils/chown.c
index 43d62b1..e714b2d 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -85,7 +85,7 @@
}
/* Ok, ready to do the deed now */
- while (optind++ < argc-1) {
+ while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;