summaryrefslogtreecommitdiff
path: root/lib/Text
diff options
context:
space:
mode:
authoralexander_bluhm@genua.de <alexander_bluhm@genua.de>2006-11-17 01:31:48 -0800
committerNicholas Clark <nick@ccl4.org>2006-11-18 16:14:18 +0000
commit9983eac85a219459e624c0c0778fb334b52e6ead (patch)
tree0a862137ef1d55fdfd759b8fd02b31521b4214c5 /lib/Text
parent46f0e7a52641befa6f3ed588e017a5454a12be04 (diff)
downloadperl-9983eac85a219459e624c0c0778fb334b52e6ead.tar.gz
[perl #40921] shellwords.pl cannot handle trailing backslash
From: alexander_bluhm@genua.de (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.5.HEAD-32013-1163784707-1469.40921-75-0@perl.org> (and convert the example to a test) p4raw-id: //depot/perl@29316
Diffstat (limited to 'lib/Text')
-rw-r--r--lib/Text/ParseWords.pm2
-rwxr-xr-xlib/Text/ParseWords.t8
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Text/ParseWords.pm b/lib/Text/ParseWords.pm
index 1411986cd9..78f7b24c94 100644
--- a/lib/Text/ParseWords.pm
+++ b/lib/Text/ParseWords.pm
@@ -133,7 +133,7 @@ sub old_shellwords {
Carp::carp("Unmatched single quote: $_");
return();
}
- elsif (s/\A\\(.)//s) {
+ elsif (s/\A\\(.?)//s) {
$snippet = $1;
}
elsif (s/\A([^\s\\'"]+)//) {
diff --git a/lib/Text/ParseWords.t b/lib/Text/ParseWords.t
index a0a6e5172e..57bdbd0309 100755
--- a/lib/Text/ParseWords.t
+++ b/lib/Text/ParseWords.t
@@ -7,7 +7,7 @@ BEGIN {
use warnings;
use Text::ParseWords;
-use Test::More tests => 26;
+use Test::More tests => 27;
@words = shellwords(qq(foo "bar quiz" zoo));
is($words[0], 'foo');
@@ -117,3 +117,9 @@ is($result, "");
# from parse_line, so it's behavior is more like /bin/sh
$result = join('|', shellwords(" aa \\ \\ bb ", " \\ ", "cc dd ee\\ "));
is($result, "aa| | bb| |cc|dd|ee ");
+
+$SIG{ALRM} = sub {die "Timeout!"};
+alarm(3);
+@words = Text::ParseWords::old_shellwords("foo\\");
+is(@words, 1);
+alarm(0);