diff options
Diffstat (limited to 'lib/bundler/source.rb')
-rw-r--r-- | lib/bundler/source.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index b3f94b465e..fe9ac1dbfd 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -608,11 +608,17 @@ module Bundler Digest::SHA1.hexdigest(input) end - # Escape an argument for shell commands. To support a single quote - # within the argument we must end the string, escape the quote and - # restart. + # Escape an argument for shell commands. def escape(string) - "'#{string.to_s.gsub("'") {|s| "'\\''"}}'" + if Bundler::WINDOWS + # Windows quoting requires double quotes only, with double quotes + # inside the string escaped by being doubled. + '"' + string.gsub('"') {|s| '""'} + '"' + else + # Bash requires single quoted strings, with the single quotes escaped + # by ending the string, escaping the quote, and restarting the string. + "'" + string.gsub("'") {|s| "'\\''"} + "'" + end end def cache_path |