Fix comments about @INC ordering
[p5sagit/p5-mst-13.2.git] / lib / shellwords.pl
index 124c29a..1c2c894 100644 (file)
@@ -1,3 +1,6 @@
+;# This legacy library is deprecated and will be removed in a future
+;# release of perl.
+;#
 ;# shellwords.pl
 ;#
 ;# Usage:
 ;#     or
 ;#     @words = shellwords();          # defaults to $_ (and clobbers it)
 
-sub shellwords {
-    local *_ = \join('', @_) if @_;
-    my (@words, $snippet);
+warn( "The 'shellwords.pl' legacy library is deprecated and will be"
+      . " removed in the next major release of perl. Please use the"
+      . " Text::ParseWords module instead." );
+
+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;