Allow a closing brace after an "use VERSION"
[p5sagit/p5-mst-13.2.git] / lib / shellwords.pl
index 5d593da..1c2c894 100644 (file)
@@ -1,48 +1,21 @@
+;# This legacy library is deprecated and will be removed in a future
+;# release of perl.
+;#
 ;# shellwords.pl
 ;#
 ;# 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)
+
+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." );
 
-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;