From a0ee5592119048c38ed05406e57eb95020334fd4 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 13 Sep 2024 23:05:06 -0700 Subject: [PATCH] omnibus/cli: only match override value against regex for strings As of Ruby 3.2, `true =~ /regex/` raises an exception (a NoMethodError for `=~`) instead of returning `nil` (seen in 3.1 and earlier), so using `--override key:true` (and false / nil) fails with an error. Instead of always comparing value against a regular expression, only do it if the value didn't match a known true/false/nil value. This appears to stem from . Signed-off-by: Noel Cower --- lib/omnibus/cli/base.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/omnibus/cli/base.rb b/lib/omnibus/cli/base.rb index ace83e702..1c2d88e90 100644 --- a/lib/omnibus/cli/base.rb +++ b/lib/omnibus/cli/base.rb @@ -69,9 +69,7 @@ def initialize(args, options, config) if %w{true false nil}.include?(value) log.debug(log_key) { "Detected #{value.inspect} should be an object" } value = { "true" => true, "false" => false, "nil" => nil }[value] - end - - if value =~ /\A[[:digit:]]+\Z/ + elsif value =~ /\A[[:digit:]]+\Z/ log.debug(log_key) { "Detected #{value.inspect} should be an integer" } value = value.to_i end