summaryrefslogtreecommitdiff
path: root/test/test_shellwords.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 05:19:03 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-13 05:19:03 +0000
commit273d5004bec3138b6ca7fd17f4f12e3c2f2abf2f (patch)
treeb9b3c7d4f3759ea7efcce099355c8cd09a3a63a0 /test/test_shellwords.rb
parentc53479ae8afa9c32966a38f6b754f8e31f130b96 (diff)
* lib/shellwords.rb (Shellwords#shellsplit): Document that this
method does not treat shell metacharacters as such. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_shellwords.rb')
-rw-r--r--test/test_shellwords.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/test_shellwords.rb b/test/test_shellwords.rb
index e70e0d72bf2..3ead5f7c491 100644
--- a/test/test_shellwords.rb
+++ b/test/test_shellwords.rb
@@ -6,15 +6,15 @@ class TestShellwords < Test::Unit::TestCase
include Shellwords
- def setup
- @not_string = Class.new
- @cmd = "ruby my_prog.rb | less"
- end
-
+ def test_shellwords
+ cmd1 = "ruby -i'.bak' -pe \"sub /foo/, '\\\\&bar'\" foobar\\ me.txt\n"
+ assert_equal(['ruby', '-i.bak', '-pe', "sub /foo/, '\\&bar'", "foobar me.txt"],
+ shellwords(cmd1))
- def test_string
- assert_instance_of(Array, shellwords(@cmd))
- assert_equal(4, shellwords(@cmd).length)
+ # shellwords does not interpret meta-characters
+ cmd2 = "ruby my_prog.rb | less"
+ assert_equal(['ruby', 'my_prog.rb', '|', 'less'],
+ shellwords(cmd2))
end
def test_unmatched_double_quote