diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 02:43:56 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 02:43:56 +0000 |
commit | fdfb8804c0d2665e8b82f211fe327b887f2d0b01 (patch) | |
tree | 5d698be5b7f13b939d340d524c2fe8fca33d459a /lib | |
parent | 373489bb4e292b2aea249ed6de71eba883ea1610 (diff) | |
download | ruby-fdfb8804c0d2665e8b82f211fe327b887f2d0b01.tar.gz |
* lib/shellwords.rb: Turn on frozen-string-literal after fixing
shellsplit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/shellwords.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/shellwords.rb b/lib/shellwords.rb index ccc1c31060..d02d3b06d5 100644 --- a/lib/shellwords.rb +++ b/lib/shellwords.rb @@ -1,4 +1,4 @@ -# frozen-string-literal: false +# frozen-string-literal: true ## # == Manipulates strings like the UNIX Bourne shell # @@ -70,14 +70,14 @@ module Shellwords # argv #=> ["here", "are", "two words"] def shellsplit(line) words = [] - field = '' + field = String.new line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do |word, sq, dq, esc, garbage, sep| raise ArgumentError, "Unmatched double quote: #{line.inspect}" if garbage field << (word || sq || (dq || esc).gsub(/\\(.)/, '\\1')) if sep words << field - field = '' + field = String.new end end words |