summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/shellwords.rb2
-rw-r--r--test/test_shellwords.rb13
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/shellwords.rb b/lib/shellwords.rb
index d02d3b06d54..66092c8999a 100644
--- a/lib/shellwords.rb
+++ b/lib/shellwords.rb
@@ -125,7 +125,7 @@ module Shellwords
str = str.to_s
# An empty argument will be skipped, so return empty quotes.
- return "''" if str.empty?
+ return "''".dup if str.empty?
str = str.dup
diff --git a/test/test_shellwords.rb b/test/test_shellwords.rb
index 59cdbe96dc9..e70e0d72bf2 100644
--- a/test/test_shellwords.rb
+++ b/test/test_shellwords.rb
@@ -48,8 +48,17 @@ class TestShellwords < Test::Unit::TestCase
end
def test_stringification
- assert_equal "3", shellescape(3)
- assert_equal "ps -p #{$$}", ['ps', '-p', $$].shelljoin
+ three = shellescape(3)
+ 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
def test_multibyte_characters