This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix failing Test::Simple test
[perl5.git] / lib / shellwords.pl
index 124c29a..b3ef33e 100644 (file)
@@ -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;