diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-08-17 14:26:15 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-08-17 14:26:15 -0700 |
commit | 4901e5117d1eed5c76736a1ea5a5279e87aee079 (patch) | |
tree | 75123d96b1d4160b56dcdc9fd88985811f518f8c /chef-config/lib/chef-config/path_helper.rb | |
parent | b2acd574f7273b823789dfd3dfbc626474dbae67 (diff) | |
download | chef-4901e5117d1eed5c76736a1ea5a5279e87aee079.tar.gz |
fix to render file_cache_path more "windows-native"
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'chef-config/lib/chef-config/path_helper.rb')
-rw-r--r-- | chef-config/lib/chef-config/path_helper.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb index 9d3db7621d..8fe45febfc 100644 --- a/chef-config/lib/chef-config/path_helper.rb +++ b/chef-config/lib/chef-config/path_helper.rb @@ -156,6 +156,26 @@ module ChefConfig end end + # This is not just escaping for something like use in Regexps, or in globs. For the former + # just use Regexp.escape. For the latter, use escape_glob_dir below. + # + # This is escaping where the path to be rendered is being put into a ruby file which will + # later be read back by ruby (or something similar) so we need quadruple backslashes. + # + # In order to print: + # + # file_cache_path "C:\\chef" + # + # We need to convert "C:\chef" to "C:\\\\chef" to interpolate into a string which is rendered + # into the output file with that line in it. + # + # @param path [String] the path to escape + # @return [String] the escaped path + # + def self.escapepath(path) + path.gsub(BACKSLASH, BACKSLASH * 4) + end + def self.paths_eql?(path1, path2, windows: ChefUtils.windows?) canonical_path(path1, windows: windows) == canonical_path(path2, windows: windows) end |