mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
lib/shellwords.rb: do not change API with frozen-string-literal
This fixes a bug introduced in r53066 when attempting to shellescape an empty string. * lib/shellwords.rb (shellescape): duplicate frozen literal * test/test_shellwords.rb (test_stringification): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2854a7f121
commit
bd13788fdb
2 changed files with 12 additions and 3 deletions
|
@ -125,7 +125,7 @@ module Shellwords
|
||||||
str = str.to_s
|
str = str.to_s
|
||||||
|
|
||||||
# An empty argument will be skipped, so return empty quotes.
|
# An empty argument will be skipped, so return empty quotes.
|
||||||
return "''" if str.empty?
|
return "''".dup if str.empty?
|
||||||
|
|
||||||
str = str.dup
|
str = str.dup
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,17 @@ class TestShellwords < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stringification
|
def test_stringification
|
||||||
assert_equal "3", shellescape(3)
|
three = shellescape(3)
|
||||||
assert_equal "ps -p #{$$}", ['ps', '-p', $$].shelljoin
|
assert_equal '3', three
|
||||||
|
assert_not_predicate three, :frozen?
|
||||||
|
|
||||||
|
empty = shellescape('')
|
||||||
|
assert_equal "''", empty
|
||||||
|
assert_not_predicate empty, :frozen?
|
||||||
|
|
||||||
|
joined = ['ps', '-p', $$].shelljoin
|
||||||
|
assert_equal "ps -p #{$$}", joined
|
||||||
|
assert_not_predicate joined, :frozen?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_multibyte_characters
|
def test_multibyte_characters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue