diff --git a/lib/net/scp.rb b/lib/net/scp.rb index 3713656..67f9d49 100644 --- a/lib/net/scp.rb +++ b/lib/net/scp.rb @@ -344,11 +344,15 @@ def scp_command(mode, options) def start_command(mode, local, remote, options={}, &callback) session.open_channel do |channel| - if options[:shell] - escaped_file = shellescape(remote).gsub(/'/) { |m| "'\\''" } - command = "#{options[:shell]} -c '#{scp_command(mode, options)} #{escaped_file}'" + if options[:windows_path] + command = "#{scp_command(mode, options)} #{remote.gsub('\\', '/')}" else - command = "#{scp_command(mode, options)} #{shellescape remote}" + if options[:shell] + escaped_file = shellescape(remote).gsub(/'/) { |m| "'\\''" } + command = "#{options[:shell]} -c '#{scp_command(mode, options)} #{escaped_file}'" + else + command = "#{scp_command(mode, options)} #{shellescape remote}" + end end channel.exec(command) do |ch, success|