Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/net/scp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume :windows_path is a new option. Does it means that the remote uses windows style encoding?

command = "#{scp_command(mode, options)} #{remote.gsub('\\', '/')}"
else
command = "#{scp_command(mode, options)} #{shellescape remote}"
if options[:shell]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elsif options[:shell] for readability? 🙂

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|
Expand Down