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 168991f..b3ef33e 100644 (file)
@@ -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;