Project

General

Profile

Feature #16741

Updated by sawa (Tsuyoshi Sawada) 8 months ago

`shellwords` module was originally designed and developed for *NIX, and currently works like this: **Reproduce process** 

 ```ruby ```irb 
 irb(main):002:0> require 'shellwords' 

 
 => true 
 irb(main):005:0> Shellwords.shellescape("/home/me/test with space.txt") 
 # => "/home/me/test\\ with\\ space.txt" 

 Shellwords.shellescape("C:\Program Files") 
 # => "C:Program\\ Files" 
 ``` 

 **Expected result and the reason why you expect** 

 I understand that `shellwords` module originally was designed & developed for *NIX but I think it's a good opportunity chance to extend it to support Windows. According to [2], it Windows too 

 For batch looks like using quotations quotation is the only a single option according to [2] if we need it, for example for paths used in a batch script that have space inside. I propose: inside of it. 
 Proposed implementation: 

 ```ruby ```irb 
 irb(main):004:0> Shellwords.shellescape("C:\Program Files") 
 # => "\"C:\Program Files\"" 
 ``` 

 Current implementation: 

 ```irb 
 irb(main):004:0> Shellwords.shellescape("C:\Program Files") 
 => "C:Program\\ Files" 
 ``` 

 Links 
 1. https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file 
 2. https://superuser.com/a/962816/245944 
 3. https://ss64.com/nt/syntax-esc.html

Back