summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-04-11 00:06:20 +0800
committerruki <[email protected]>2026-04-11 00:06:20 +0800
commit14f982f0778fcb993ff889e840d9e401c8e344fe (patch)
treea56cbb18aba635b4c07845d30031ddf003ed5ef1
parent4dde60c71adf3de9b1c49f6f28bb235673846ae9 (diff)
improve option.booleanoption
-rw-r--r--xmake/core/base/option.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index e8f6a4fb8..4969de689 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -375,11 +375,18 @@ end
-- @return true, false, or nil
--
function option.boolean(value)
- if type(value) == "string" then
+ local value_type = type(value)
+ if value_type == "string" then
local v = value:lower()
- if v == "true" or v == "yes" or v == "y" then value = true
- elseif v == "false" or v == "no" or v == "n" then value = false
+ if v == "true" or v == "yes" or v == "y" then
+ value = true
+ elseif v == "false" or v == "no" or v == "n" then
+ value = false
+ else
+ value = nil
end
+ elseif value_type ~= "boolean" then
+ value = nil
end
return value
end