X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshellwords.pl;h=b3ef33ebd9f0f42f58646037425e02bff1cab756;hb=2db40e90730d5fd105e3f74faa4d22f352568b99;hp=124c29a49742e4d5f779eaefd80911cd257f3efe;hpb=08b96d1f9dac8367df484da44f467f9c8ad5dba9;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/shellwords.pl b/lib/shellwords.pl index 124c29a..b3ef33e 100644 --- a/lib/shellwords.pl +++ b/lib/shellwords.pl @@ -8,40 +8,7 @@ ;# or ;# @words = shellwords(); # defaults to $_ (and clobbers it) -sub shellwords { - local *_ = \join('', @_) if @_; - my (@words, $snippet); +require Text::ParseWords; +*shellwords = \&Text::ParseWords::old_shellwords; - s/\A\s+//; - while ($_ ne '') { - my $field = substr($_, 0, 0); # leave results tainted - for (;;) { - if (s/\A"(([^"\\]|\\.)*)"//s) { - ($snippet = $1) =~ s#\\(.)#$1#sg; - } - elsif (/\A"/) { - die "Unmatched double quote: $_\n"; - } - elsif (s/\A'(([^'\\]|\\.)*)'//s) { - ($snippet = $1) =~ s#\\(.)#$1#sg; - } - elsif (/\A'/) { - die "Unmatched single quote: $_\n"; - } - elsif (s/\A\\(.)//s) { - $snippet = $1; - } - elsif (s/\A([^\s\\'"]+)//) { - $snippet = $1; - } - else { - s/\A\s+//; - last; - } - $field .= $snippet; - } - push(@words, $field); - } - return @words; -} 1;