Skip to content

Commit a0ee559

Browse files
committed
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 <https://bugs.ruby-lang.org/issues/15231>. Signed-off-by: Noel Cower <[email protected]>
1 parent 332bce5 commit a0ee559

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/omnibus/cli/base.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def initialize(args, options, config)
6969
if %w{true false nil}.include?(value)
7070
log.debug(log_key) { "Detected #{value.inspect} should be an object" }
7171
value = { "true" => true, "false" => false, "nil" => nil }[value]
72-
end
73-
74-
if value =~ /\A[[:digit:]]+\Z/
72+
elsif value =~ /\A[[:digit:]]+\Z/
7573
log.debug(log_key) { "Detected #{value.inspect} should be an integer" }
7674
value = value.to_i
7775
end

0 commit comments

Comments
 (0)