Thank you kindly, Tyre for :

Commands with arguments enclosed in Double quotation marks (e.g. filenames or objects with embedded blanks) should be parsed correctly. e.g.:
console command "edit-scale" don't accept prim names with embedded blanks
edit-scale Prim 20x20x20 20 20 20
Region# :
edit-scale "Prim 20x20x20" 20 20 20
Region# :
edit-scale Prim20x20x20 20 20 20
Searching for Primitive: 'Prim20x20x20'
Edited scale of Primitive: Prim20x20x20
Region# :
0.6.0-stable
Charles Krinke 2008-04-23 14:31:54 +00:00
parent e456cb7533
commit 67f2b89bf6
1 changed files with 16 additions and 10 deletions

View File

@ -26,7 +26,9 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
@ -368,23 +370,27 @@ namespace OpenSim.Framework.Console
RunCommand(tempstr); RunCommand(tempstr);
} }
public void RunCommand(string command) public void RunCommand(string cmdline)
{ {
string[] tempstrarray; Regex Extractor = new Regex(@"(['""][^""]+['""])\s*|([^\s]+)\s*", RegexOptions.Compiled);
tempstrarray = command.Split(' '); char[] delims = {' ', '"'};
string cmd = tempstrarray[0]; MatchCollection matches = Extractor.Matches(cmdline);
Array.Reverse(tempstrarray); // Get matches
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1); string cmd = matches[0].Value.Trim(delims);
Array.Reverse(tempstrarray); string[] cmdparams = new string[matches.Count - 1];
string[] cmdparams = (string[]) tempstrarray;
for (int i = 1; i < matches.Count; i++)
{
cmdparams[i-1] = matches[i].Value.Trim(delims);
}
try try
{ {
RunCmd(cmd, cmdparams); RunCmd(cmd, cmdparams);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", command, e.ToString()); m_log.ErrorFormat("[Console]: Command [{0}] failed with exception {1}", cmdline, e.ToString());
} }
} }