aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Console/ConsoleBase.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Console/ConsoleBase.cs26
1 files changed, 16 insertions, 10 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 27ff340..1d92ed1 100644
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text.RegularExpressions;
30using System.Diagnostics; 32using System.Diagnostics;
31using System.Net; 33using System.Net;
32using System.Reflection; 34using System.Reflection;
@@ -368,23 +370,27 @@ namespace OpenSim.Framework.Console
368 RunCommand(tempstr); 370 RunCommand(tempstr);
369 } 371 }
370 372
371 public void RunCommand(string command) 373 public void RunCommand(string cmdline)
372 { 374 {
373 string[] tempstrarray; 375 Regex Extractor = new Regex(@"(['""][^""]+['""])\s*|([^\s]+)\s*", RegexOptions.Compiled);
374 tempstrarray = command.Split(' '); 376 char[] delims = {' ', '"'};
375 string cmd = tempstrarray[0]; 377 MatchCollection matches = Extractor.Matches(cmdline);
376 Array.Reverse(tempstrarray); 378 // Get matches
377 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1); 379 string cmd = matches[0].Value.Trim(delims);
378 Array.Reverse(tempstrarray); 380 string[] cmdparams = new string[matches.Count - 1];
379 string[] cmdparams = (string[]) tempstrarray; 381
380 382 for (int i = 1; i < matches.Count; i++)
383 {
384 cmdparams[i-1] = matches[i].Value.Trim(delims);
385 }
386
381 try 387 try
382 { 388 {
383 RunCmd(cmd, cmdparams); 389 RunCmd(cmd, cmdparams);
384 } 390 }
385 catch (Exception e) 391 catch (Exception e)
386 { 392 {
387 m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", command, e.ToString()); 393 m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", cmdline, e.ToString());
388 } 394 }
389 } 395 }
390 396