summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/core/base/option.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 8ebe529ed..eb779b097 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -189,7 +189,8 @@ function option.init(menu)
assert(context)
-- parse _ARGV
- local argv = xmake._ARGV
+ local argv = xmake._ARGV
+ local argkv_end = false
local _iter, _s, _k = ipairs(argv)
while true do
@@ -203,10 +204,9 @@ function option.init(menu)
-- parse key and value
local key, value
local i = arg:find("=", 1, true)
- local hasspace = arg:find("%s")
-- key=value?
- if i and not hasspace then
+ if i and not argkv_end then
key = arg:sub(1, i - 1)
value = arg:sub(i + 1)
-- only key?
@@ -217,11 +217,11 @@ function option.init(menu)
-- --key?
local prefix = 0
- if not hasspace and key:startswith("--") then
+ if not argkv_end and key:startswith("--") then
key = key:sub(3)
prefix = 2
-- -k?
- elseif not hasspace and key:startswith("-") then
+ elseif not argkv_end and key:startswith("-") then
key = key:sub(2)
prefix = 1
end
@@ -378,6 +378,9 @@ function option.init(menu)
-- value?
else
+ -- stop to parse key-value arguments
+ argkv_end = true
+
-- find a value option with name
local opt = nil
for _, o in ipairs(option._taskmenu().options) do