Module: WindowsShellwords

Defined in:
fastlane_core/lib/fastlane_core/core_ext/shellwords.rb

Overview

Windows implementation

Class Method Summary collapse

Class Method Details

.shellescape(str) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'fastlane_core/lib/fastlane_core/core_ext/shellwords.rb', line 44

def shellescape(str)
  str = str.to_s

  # An empty argument will be skipped, so return empty quotes.
  # https://github.com/ruby/ruby/blob/a6413848153e6c37f6b0fea64e3e871460732e34/lib/shellwords.rb#L142-L143
  return '""'.dup if str.empty?

  str = str.dup

  # wrap in double quotes if contains space
  if str =~ /\s/
    # double quotes have to be doubled if will be quoted
    str.gsub!('"', '""')
    return '"' + str + '"'
  else
    return str
  end
end