* 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
This commit is contained in:
parent
c53479ae8a
commit
273d5004be
@ -1,3 +1,8 @@
|
|||||||
|
Sun Dec 13 14:16:09 2015 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* lib/shellwords.rb (Shellwords#shellsplit): Document that this
|
||||||
|
method does not treat shell metacharacters as such.
|
||||||
|
|
||||||
Sun Dec 13 12:17:43 2015 Eric Wong <e@80x24.org>
|
Sun Dec 13 12:17:43 2015 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* lib/shellwords.rb (shellescape): duplicate frozen literal
|
* lib/shellwords.rb (shellescape): duplicate frozen literal
|
||||||
|
@ -64,6 +64,13 @@ module Shellwords
|
|||||||
# argv = Shellwords.split('here are "two words"')
|
# argv = Shellwords.split('here are "two words"')
|
||||||
# argv #=> ["here", "are", "two words"]
|
# argv #=> ["here", "are", "two words"]
|
||||||
#
|
#
|
||||||
|
# Note, however, that this is not a command line parser. Shell
|
||||||
|
# metacharacters except for the single and double quotes and
|
||||||
|
# backslash are not treated as such.
|
||||||
|
#
|
||||||
|
# argv = Shellwords.split('ruby my_prog.rb | less')
|
||||||
|
# argv #=> ["ruby", "my_prog.rb", "|", "less"]
|
||||||
|
#
|
||||||
# String#shellsplit is a shortcut for this function.
|
# String#shellsplit is a shortcut for this function.
|
||||||
#
|
#
|
||||||
# argv = 'here are "two words"'.shellsplit
|
# argv = 'here are "two words"'.shellsplit
|
||||||
|
@ -6,15 +6,15 @@ class TestShellwords < Test::Unit::TestCase
|
|||||||
|
|
||||||
include Shellwords
|
include Shellwords
|
||||||
|
|
||||||
def setup
|
def test_shellwords
|
||||||
@not_string = Class.new
|
cmd1 = "ruby -i'.bak' -pe \"sub /foo/, '\\\\&bar'\" foobar\\ me.txt\n"
|
||||||
@cmd = "ruby my_prog.rb | less"
|
assert_equal(['ruby', '-i.bak', '-pe', "sub /foo/, '\\&bar'", "foobar me.txt"],
|
||||||
end
|
shellwords(cmd1))
|
||||||
|
|
||||||
|
# shellwords does not interpret meta-characters
|
||||||
def test_string
|
cmd2 = "ruby my_prog.rb | less"
|
||||||
assert_instance_of(Array, shellwords(@cmd))
|
assert_equal(['ruby', 'my_prog.rb', '|', 'less'],
|
||||||
assert_equal(4, shellwords(@cmd).length)
|
shellwords(cmd2))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unmatched_double_quote
|
def test_unmatched_double_quote
|
||||||
|
Loading…
x
Reference in New Issue
Block a user