changeset 697:ca9a1d8e2531

Set optc when optstring NULL.
author Rob Landley <rob@landley.net>
date Fri, 16 Nov 2012 00:46:39 -0600
parents 99ca30ad3d2b
children 078138791b5c
files main.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Fri Nov 16 00:35:46 2012 -0600
+++ b/main.c	Fri Nov 16 00:46:39 2012 -0600
@@ -84,7 +84,10 @@
   toys.which = which;
   toys.argv = argv;
   if (NEED_OPTIONS && which->options) get_optflags();
-  else toys.optargs = argv+1;
+  else {
+    toys.optargs = argv+1;
+    for (toys.optc=0; toys.optargs[toys.optc]; toys.optc++);
+  }
   toys.old_umask = umask(0);
   if (!(which->flags & TOYFLAG_UMASK)) umask(toys.old_umask);
 }