summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 04:58:48 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 04:58:48 +0000
commit2da5ae4232ebb4b9b2cabd8bbb8ca5ee224afdbf (patch)
tree44fd2efaf75c6abc329d97c7219e17ba631ea7ff /test
parent7a78133a412df8077a19112af682cca2377400a0 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/test_shellwords.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/test_shellwords.rb b/test/test_shellwords.rb
index 2916d5dda6..16949c02d3 100644
--- a/test/test_shellwords.rb
+++ b/test/test_shellwords.rb
@@ -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