Permalink
Browse files

Add double quotes back to arguments for the re-parsing done by Magnum.

  • Loading branch information...
1 parent fc30c2c commit bd26125c0548b3e2e61f81f734ff4afbc003a65f @rossbeehler rossbeehler committed Feb 1, 2012
Showing with 23 additions and 1 deletion.
  1. +23 −1 product/dropkick.console/Program.cs
@@ -34,7 +34,29 @@ static void Main(string[] args)
Environment.Exit(1);
}
- Runner.Deploy(args.Aggregate("", (a, b) => a + " " + b).Trim());
+ AddQuotesBackToArgs(args);
+
+ Runner.Deploy(string.Join(" ", args));
+ }
+
+ private static void AddQuotesBackToArgs(string[] args)
+ {
+ if (args == null || args.Length <= 0) return;
+
+ for (var i = 0; i < args.Length; i++)
+ {
+ if (WasSurroundedByDoubleQuotes(args[i]))
+ args[i] = '"' + args[i] + '"';
+ }
+ }
+
+ static bool WasSurroundedByDoubleQuotes(string argument)
+ {
+ var indexOf = Environment.CommandLine.IndexOf(argument);
+ return indexOf > 0 &&
+ indexOf + argument.Length < Environment.CommandLine.Length &&
+ Environment.CommandLine[indexOf - 1] == '"' &&
+ Environment.CommandLine[indexOf + argument.Length] == '"';
}
private static string GetHelpMessage()

0 comments on commit bd26125

Please sign in to comment.