17
17
# - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
21
20
# Splits a string into an array of tokens in the same way the UNIX
24
23
# argv = Shellwords.split('here are "two words"')
25
24
# argv #=> ["here", "are", "two words"]
29
28
# argv = 'here are "two words"'.shellsplit
30
29
# argv #=> ["here", "are", "two words"]
35
33
line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
36
34
|word, sq, dq, esc, garbage, sep|
37
35
raise ArgumentError, "Unmatched double quote: #{line.inspect}" if garbage