From: nobu@... Date: 2020-03-29T07:54:06+00:00 Subject: [ruby-core:97615] [Ruby master Feature#16741] Implement Shellwords.shellescape correctly for Windows Issue #16741 has been updated by nobu (Nobuyoshi Nakada). I'm curious for what purpose you need to escape paths. To pass it to another program, it is better to `spawn` or `system` with split array. ---------------------------------------- Feature #16741: Implement Shellwords.shellescape correctly for Windows https://bugs.ruby-lang.org/issues/16741#change-84806 * Author: abobrikovich (Alexander Bobrikovich) * Status: Open * Priority: Normal ---------------------------------------- `shellwords` module was originally designed and developed for *NIX, and currently works like this: ```ruby require 'shellwords' Shellwords.shellescape("/home/me/test with space.txt") # => "/home/me/test\\ with\\ space.txt" Shellwords.shellescape("C:\Program Files") # => "C:Program\\ Files" ``` I think it's a good opportunity to extend it to support Windows. According to [2], it looks like using quotations is the only option for paths used in a batch script that have space inside. I propose: ```ruby 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 -- https://bugs.ruby-lang.org/ Unsubscribe: