From: Tobias Ulmer Date: Fri, 17 Aug 2012 12:27:09 +0000 (+0200) Subject: Tighten argument parsing, fixes #1010 X-Git-Tag: e2factory-2.3.13rc1~161 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=1c32df484fe2a4b56c6a30ee7503d543cdd88dd9;p=e2factory.git Tighten argument parsing, fixes #1010 Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2option.lua b/generic/e2option.lua index 0cad091..d6ea094 100644 --- a/generic/e2option.lua +++ b/generic/e2option.lua @@ -295,10 +295,21 @@ function e2option.parse(args) if s then opt = aliases[opt] or opt if options[opt] then + if options[opt].type == "flag" then + e2lib.abort(string.format( + "option '%s' does not take an argument\n".. + "Try the --help option for usage information.", opt)) + end + local proc = options[opt].proc - if proc then val = proc(val) end + if proc then + val = proc(val) + end + opts[opt] = val - else e2option.usage(1) + else + e2lib.abort(string.format("unknown option: %s\n".. + "Try the --help option for usage information.", opt)) end else s, e, opt = string.find(v, "^%-%-?(.*)$") @@ -331,7 +342,7 @@ function e2option.parse(args) for k, v in pairs(set) do if not options[v] then - e2lib.abort(string.format("invalid option: %s\n".. + e2lib.abort(string.format("unknown option: %s\n".. "Try the --help option for usage information.", opt)) else table.insert(args, "-" .. v)