From 7d47ec4c46792e70481959673fbfdec2adba1719 Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Wed, 2 Jul 2014 17:04:58 +0530 Subject: [PATCH] Properly handle invalid arguments in builtins Fixes #1522 --- wgetopt.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wgetopt.cpp b/wgetopt.cpp index ecf1121e5..2d2117f6d 100644 --- a/wgetopt.cpp +++ b/wgetopt.cpp @@ -638,7 +638,10 @@ _wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, cons fwprintf(stderr, _(L"%ls: Invalid option -- %lc\n"), argv[0], c); } woptopt = c; - woptind++; + + if (*nextchar != '\0') + woptind++; + return '?'; } if (temp[1] == ':')