Implement Shellwords.shellescape correctly for Windows
shellwords module was originally designed and developed for *NIX, and currently works like this:
Shellwords.shellescape("/home/me/test with space.txt")
# => "/home/me/test\\ with\\ space.txt"
# => "C:Program\\ Files"
I think it's a good opportunity to extend it to support Windows. According to , it looks like using quotations is the only option for paths used in a batch script that have space inside. I propose:
# => "\"C:\Program Files\""
I think adding
Shellwords.cmdescape is better than changing
Some environments on Windows support both bash and cmd.
I agree with @znz. IMO, a gem named
cmdwords or something would be a good start for the feature instead of directly extending
- Description updated (diff)
- Subject changed from Implement Shellwords.shellescape correctly on Windows to Implement Shellwords.shellescape correctly for Windows
I'm curious for what purpose you need to escape paths.
To pass it to another program, it is better to
system with split array.
Also available in: Atom