mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
Fix the handling of the backslash in double quotes
* lib/shellwords.rb (Shellwords#shellsplit): Fix the handling of the backslash in double quotes to conform to the standard. [ruby-core:63807] [Bug #10055] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a78133a41
commit
2da5ae4232
3 changed files with 34 additions and 8 deletions
|
@ -40,12 +40,24 @@ class TestShellwords < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_backslashes
|
||||
cmdline, expected = [
|
||||
%q{/a//b///c////d/////e/ "/a//b///c////d/////e/ "'/a//b///c////d/////e/ '/a//b///c////d/////e/ },
|
||||
%q{a/b/c//d//e a/b/c//d//e /a//b///c////d/////e/ a/b/c//d//e }
|
||||
].map { |str| str.tr("/", "\\\\") }
|
||||
|
||||
assert_equal [expected], shellwords(cmdline)
|
||||
[
|
||||
[
|
||||
%q{/a//b///c////d/////e/ "/a//b///c////d/////e/ "'/a//b///c////d/////e/ '/a//b///c////d/////e/ },
|
||||
'a/b/c//d//e /a/b//c//d///e/ /a//b///c////d/////e/ a/b/c//d//e '
|
||||
],
|
||||
[
|
||||
%q{printf %s /"/$/`///"/r/n},
|
||||
'printf', '%s', '"$`/"rn'
|
||||
],
|
||||
[
|
||||
%q{printf %s "/"/$/`///"/r/n"},
|
||||
'printf', '%s', '"$`/"/r/n'
|
||||
]
|
||||
].map { |strs|
|
||||
cmdline, *expected = strs.map { |str| str.tr("/", "\\\\") }
|
||||
assert_equal expected, shellwords(cmdline)
|
||||
}
|
||||
end
|
||||
|
||||
def test_stringification
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue