Set optc when optstring NULL.

This commit is contained in:
Rob Landley 2012-11-16 00:46:39 -06:00
parent caf39c2682
commit 4521f416ba

5
main.c
View File

@ -84,7 +84,10 @@ void toy_init(struct toy_list *which, char *argv[])
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);
}