Actions
Bug #8028
closedShellwords.escape works incorrect under windows
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p0 (2013-02-24) [i386-mingw32]
Description
Shellwords.escape works incorrect under windows (tested for Windows 7
x64), here is example:
Actual result:
irb(main):001:0> require 'shellwords'
=> true
irb(main):002:0> `echo #{Shellwords.escape( '123>' )} test` # should
echo "123> test", but echo nothing
=> ""
irb(main):003:0> File.read( 'test' ) # but writes file "test"
=> "123\\\n"
Expected result:
irb(main):001:0> `echo 132^> test` # the correct escape sequence, echoed
"123> test"
=> "132> test\n"
Tested for "ruby 2.0.0p0 (2013-02-24) [i386-mingw32]", ruby 1.9.3, but this bug can be found in earlier ruby versions as well.
Updated by jsc (Justin Collins) about 5 years ago
Shagabutdinov (Leonid Shagabutdinov) wrote:
Shellwords.escape works incorrect under windows (tested for Windows 7
I don't believe Shellwords
is intended to work on Windows at all. According to the comments (https://github.com/ruby/ruby/blob/ee2ddf5411f51ea89a1569ea5d70b41cd4c6c7f2/lib/shellwords.rb#L3-L6):
# == Manipulates strings like the UNIX Bourne shell
#
# This module manipulates strings according to the word parsing rules
# of the UNIX Bourne shell.
Updated by nobu (Nobuyoshi Nakada) about 5 years ago
- Description updated (diff)
- Status changed from Open to Rejected
Escaping ways are various across shells, not only Windows.
Use system
with an array, e.g., system('echo', '123>')
.
Actions
Like0
Like0Like0