This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix RT #74472 Exporter.pm blocks Signal handling
[perl5.git] / lib / shellwords.pl
index 124c29a..b562f5f 100644 (file)
@@ -1,3 +1,8 @@
+warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n";
+
+;# This legacy library is deprecated and will be removed in a future
+;# release of perl.
+;#
 ;# shellwords.pl
 ;#
 ;# Usage:
@@ -8,40 +13,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;