From ab5577662592e9960577bc2a8245c5642f179619 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 16 Apr 2018 17:35:39 -0300 Subject: Fix interpretation of `--` in parse_flags Ensure that any further `--` after the first one is passed verbatim to the arguments array. --- src/luarocks/util.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6dd96e0d..9731f034 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -160,13 +160,12 @@ function util.parse_flags(...) local flags = {} local i = 1 local out = {} - local ignore_flags = false + local state = "initial" while i <= #args do local flag = args[i]:match("^%-%-(.*)") - if flag == "--" then - ignore_flags = true - end - if flag and not ignore_flags then + if state == "initial" and flag == "" then + state = "ignore_flags" + elseif state == "initial" and flag then local var,val = flag:match("([a-z_%-]*)=(.*)") if val then local vartype = supported_flags[var] @@ -205,7 +204,7 @@ function util.parse_flags(...) return { ERROR = "Invalid argument: unknown flag --"..var.."." } end end - else + elseif state == "ignore_flags" or (state == "initial" and not flag) then table.insert(out, args[i]) end i = i + 1 -- cgit v1.2.3-55-g6feb