lib/kitchen/provisioner/chef/policyfile.rb
# Escape spaces in a path in way that works with both Sh (Unix) and
# Windows.
#
# @param path [String] Path to escape
# @return [String]
# @api private
Escape spaces in a path in way that works with both Sh (Unix) and
Windows.
Escape spaces in a path in way that works with both Sh ( Unix ) and Windows .
def escape_path(path)
          if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
            if path =~ /[ \t\n\v"]/
              "\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| '\\' + m[0] }}\""
            else
              path
            end
          else
            Shellwords.escape(path)
          end
        end
def escape_path ( path ) if RbConfig :: CONFIG [ "host_os" ] =~ / mswin|mingw / if path =~ / [  \t \n \v "] / "\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| '\\' + m[0] }}\"" else path end else Shellwords . escape ( path ) end end
Escape spaces in a path in way that works with both Sh (Unix) and
Windows.
Escape spaces in a path in way that works with both Sh ( Unix ) and Windows .
# I know what you're thinking: "just use Shellwords.escape". That # method produces incorrect results on Windows with certain input # which would be a metacharacter in Sh but is not for one or more of # Windows command line parsing libraries. This covers the 99% case of # spaces in the path without breaking other stuff.
None
String
path
Path to escape
Path to escape
api
None