Author: kwilliams
Date: Mon Sep 15 21:10:04 2008
New Revision: 11792

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/lib/Module/Build/Platform/Windows.pm

Log:
Add a _quote_args() method for Windows

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Mon Sep 15 21:10:04 2008
@@ -5,6 +5,8 @@
  - Skip test in t/ext.t which tickles Text::ParseWords::shellwords() in
    5.6.2 [David Wheeler]
 
+ - Fix some shell-quoting issues on Windows.
+
 0.2808_04 - Thu Sep 11 22:51:27 PDT 2008
 
  - Backed-out incompatible Module::Finder change (first in 0.2808_02.)

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Mon Sep 15 21:10:04 2008
@@ -330,7 +330,6 @@
   # proper quoting so that the subprocess sees this same list of args.
   my ($self, @args) = @_;
 
-  my $return_args = '';
   my @quoted;
 
   for (@args) {

Modified: Module-Build/trunk/lib/Module/Build/Platform/Windows.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Platform/Windows.pm     (original)
+++ Module-Build/trunk/lib/Module/Build/Platform/Windows.pm     Mon Sep 15 
21:10:04 2008
@@ -175,6 +175,29 @@
 }
 
 
+sub _quote_args {
+  # Returns a string that can become [part of] a command line with
+  # proper quoting so that the subprocess sees this same list of args.
+  my ($self, @args) = @_;
+
+  my @quoted;
+
+  for (@args) {
+    if ( /^[^\s*?!\$<>;|'"\[\]\{\}]+$/ ) {
+      # Looks pretty safe
+      push @quoted, $_;
+    } else {
+      # XXX this will obviously have to improve - is there already a
+      # core module lying around that does proper quoting?
+      s/"/\\"/g;
+      push @quoted, qq("$_");
+    }
+  }
+
+  return join " ", @quoted;
+}
+
+
 sub split_like_shell {
   # As it turns out, Windows command-parsing is very different from
   # Unix command-parsing.  Double-quotes mean different things,

Reply via email to