diff options
| author | ruki <[email protected]> | 2016-06-17 09:59:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-06-17 09:59:39 +0800 |
| commit | e58accaa27a4e8a9631c56e7f11279f3e437e967 (patch) | |
| tree | 3635f465dcf129fb423eb988d575bf4dfe396eb2 | |
| parent | d36c9f47c2e3cf97396377e33279d6b0ce4e4ae5 (diff) | |
fix option parser bug
| -rw-r--r-- | xmake/core/base/option.lua | 13 |
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 |
