X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshellwords.pl;h=b3ef33ebd9f0f42f58646037425e02bff1cab756;hb=8b503b1a8d84e235d4f8455dd10d4d928b5a89e1;hp=ca7dc7ec2356cfcfc9695346650195deb8fb3372;hpb=86a5040c5a91f7c3b776b243300d5415c6c58021;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/shellwords.pl b/lib/shellwords.pl index ca7dc7e..b3ef33e 100644 --- a/lib/shellwords.pl +++ b/lib/shellwords.pl @@ -2,48 +2,13 @@ ;# ;# Usage: ;# require 'shellwords.pl'; -;# @words = &shellwords($line); +;# @words = shellwords($line); ;# or -;# @words = &shellwords(@lines); +;# @words = shellwords(@lines); ;# or -;# @words = &shellwords; # defaults to $_ (and clobbers it) +;# @words = shellwords(); # defaults to $_ (and clobbers it) -sub shellwords { - package shellwords; - local($_) = join('', @_) if @_; - local(@words,$snippet,$field); +require Text::ParseWords; +*shellwords = \&Text::ParseWords::old_shellwords; - s/^\s+//; - while ($_ ne '') { - $field = ''; - for (;;) { - use re 'taint'; # leave strings tainted - if (s/^"(([^"\\]|\\.)*)"//) { - ($snippet = $1) =~ s#\\(.)#$1#g; - } - elsif (/^"/) { - die "Unmatched double quote: $_\n"; - } - elsif (s/^'(([^'\\]|\\.)*)'//) { - ($snippet = $1) =~ s#\\(.)#$1#g; - } - elsif (/^'/) { - die "Unmatched single quote: $_\n"; - } - elsif (s/^\\(.)//) { - $snippet = $1; - } - elsif (s/^([^\s\\'"]+)//) { - $snippet = $1; - } - else { - s/^\s+//; - last; - } - $field .= $snippet; - } - push(@words, $field); - } - @words; -} 1;