Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support copying windows files with spaces #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ArtsiomMusin
Copy link

Some people like me use net-scp with Win32-OpenSSH... but scp doesn't work as a windows path could like this "C:\Program Files\Some folder".

The current code uses shellescape which is not friendly with windows paths. That is, every space(and maybe other chars) will be replaced with '\ ' which breaks the windows path. Moreover, net-scp doesn't expect a trailing \ in the path. So all windows \ should be replaced with /.

We've been using this change for a while and haven't seen any issues so far. Hopefully, this change will be useful for other windows folks.

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?

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? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants