diff options
author | Larry Wall <lwall@netlabs.com> | 1992-06-08 04:52:59 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1992-06-08 04:52:59 +0000 |
commit | 2b69d0c297460bce3a8d8eefe2bd0de0a6451872 (patch) | |
tree | 918d4cf76b228b2cec26aede54e1c35e6b024c25 /lib/shellwords.pl | |
parent | 32c2e4fbb7ba898d9e58e8d2292dd45b8692070d (diff) | |
download | perl-2b69d0c297460bce3a8d8eefe2bd0de0a6451872.tar.gz |
perl 4.0 patch 31: patch #20, continued
See patch #20.
Diffstat (limited to 'lib/shellwords.pl')
-rw-r--r-- | lib/shellwords.pl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/shellwords.pl b/lib/shellwords.pl index 168991fa3f..5d593daa50 100644 --- a/lib/shellwords.pl +++ b/lib/shellwords.pl @@ -1,12 +1,12 @@ -#; 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; @@ -17,12 +17,18 @@ sub shellwords { while ($_ ne '') { $field = ''; for (;;) { - if (s/^"(([^"\\]+|\\[\\"])*)"//) { + if (s/^"(([^"\\]|\\[\\"])*)"//) { ($snippet = $1) =~ s#\\(.)#$1#g; } - elsif (s/^'(([^'\\]+|\\[\\'])*)'//) { + elsif (/^"/) { + die "Unmatched double quote: $_\n"; + } + elsif (s/^'(([^'\\]|\\[\\'])*)'//) { ($snippet = $1) =~ s#\\(.)#$1#g; } + elsif (/^'/) { + die "Unmatched single quote: $_\n"; + } elsif (s/^\\(.)//) { $snippet = $1; } |