X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshellwords.pl;h=b3ef33ebd9f0f42f58646037425e02bff1cab756;hb=34ba6322b644154d55680c95808981776852ae24;hp=1c45a5a0903579fb0f58870242ce95d933e05065;hpb=a0d0e21ea6ea90a22318550944fe6cb09ae10cda;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/shellwords.pl b/lib/shellwords.pl index 1c45a5a..b3ef33e 100644 --- a/lib/shellwords.pl +++ b/lib/shellwords.pl @@ -2,47 +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 (;;) { - 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;