[ruby/optparse] Update argument check with save navigation operator

https://github.com/ruby/optparse/commit/71e2b31824
This commit is contained in:
Nobuyoshi Nakada 2025-03-10 17:02:43 +09:00 committed by git
parent dad0f876a9
commit b51450f3bd

View File

@ -780,7 +780,7 @@ class OptionParser
# Returns nil if argument is not present or begins with '-' and is not '-'.
#
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
if !(val = arg) and !(val = argv[0])&.match?(/\A(?!-.)/)
return nil, block
end
opt = (val = parse_arg(val, &error))[1]