diff --git a/lib/net/scp.rb b/lib/net/scp.rb index 1bb4333..68a702f 100644 --- a/lib/net/scp.rb +++ b/lib/net/scp.rb @@ -344,7 +344,13 @@ def scp_command(mode, options) def start_command(mode, local, remote, options={}, &callback) session.open_channel do |channel| - if options[:shell] + if options[:windows_path] + escaped_file = remote.gsub(/'/) { |m| '/' } + unless escaped_file.index(' ').nil? || escaped_file.match?(/^'.+'$/) + escaped_file = "'#{escaped_file}'" + end + command = "#{scp_command(mode, options)} #{escaped_file}" + elsif options[:shell] escaped_file = shellescape(remote).gsub(/'/) { |m| "'\\''" } command = "#{options[:shell]} -c '#{scp_command(mode, options)} #{escaped_file}'" else