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