X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshellwords.pl;h=1c45a5a0903579fb0f58870242ce95d933e05065;hb=b459063d13fd72246e4b59dcba764d7bacaf12c7;hp=168991fa3fb17a346b3d93b4b911a0e691d1564e;hpb=9ef589d8078fdf16316dec772c00e81b3c38fd22;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/shellwords.pl b/lib/shellwords.pl index 168991f..1c45a5a 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; }