[rubygems/rubygems] Extract class method used by self.method

https://github.com/rubygems/rubygems/commit/d900453ca2
This commit is contained in:
Hiroshi SHIBATA 2023-04-05 11:05:05 +09:00 committed by git
parent 7f9a5a7562
commit 8e37eb1d15

View File

@ -1269,21 +1269,17 @@ Also, a list:
$VERBOSE = old_verbose $VERBOSE = old_verbose
end end
class << self # :nodoc:
# :nodoc: ##
## # Return the join path, with escaping backticks, dollars, and
# Return the join path, with escaping backticks, dollars, and # double-quotes. Unlike `shellescape`, equal-sign is not escaped.
# double-quotes. Unlike `shellescape`, equal-sign is not escaped.
private def self.escape_path(*path)
path = File.join(*path)
def escape_path(*path) if %r{\A[-+:/=@,.\w]+\z}.match?(path)
path = File.join(*path) path
if %r{\A[-+:/=@,.\w]+\z}.match?(path) else
path "\"#{path.gsub(/[`$"]/, '\\&')}\""
else
"\"#{path.gsub(/[`$"]/, '\\&')}\""
end
end end
end end