From 4521f416ba8422563db6a762061a4a960db1bbf7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 16 Nov 2012 00:46:39 -0600 Subject: Set optc when optstring NULL. --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 7fb543ab..0b0987ad 100644 --- a/main.c +++ b/main.c @@ -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); } -- cgit v1.2.3