X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshellwords.pl;h=b3ef33ebd9f0f42f58646037425e02bff1cab756;hb=2db40e90730d5fd105e3f74faa4d22f352568b99;hp=168991fa3fb17a346b3d93b4b911a0e691d1564e;hpb=9ef589d8078fdf16316dec772c00e81b3c38fd22;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/shellwords.pl b/lib/shellwords.pl index 168991f..b3ef33e 100644 --- a/lib/shellwords.pl +++ b/lib/shellwords.pl @@ -1,42 +1,14 @@ -#; shellwords.pl -#; -#; Usage: -#; require 'shellwords.pl'; -#; @words = &shellwords($line); -#; or -#; @words = &shellwords(@lines); -#; or -#; @words = &shellwords; # defaults to $_ (and clobbers it) +;# shellwords.pl +;# +;# Usage: +;# require 'shellwords.pl'; +;# @words = shellwords($line); +;# or +;# @words = shellwords(@lines); +;# or +;# @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 (s/^'(([^'\\]+|\\[\\'])*)'//) { - ($snippet = $1) =~ s#\\(.)#$1#g; - } - elsif (s/^\\(.)//) { - $snippet = $1; - } - elsif (s/^([^\s\\'"]+)//) { - $snippet = $1; - } - else { - s/^\s+//; - last; - } - $field .= $snippet; - } - push(@words, $field); - } - @words; -} 1;