Hey,
I spent some time investigating why on Mono ir.exe (last git revision)
doesn't print the result of evaluations.
The issue lies in the processing of new lines in
Microsoft.Scripting.Core.Hosting.Shell.CommandLine.
The code is appending \n as terminating new lines, but checks for the
presence of Environment.NewLine inside the evaluated string. Obviously
it works only if Environment.NewLine is \r\n, and not \n.
Attached is a suggested patch, addressing the issue.
--
Jb Evain <[email protected]>
diff --git a/Merlin/Main/Runtime/Microsoft.Scripting/Hosting/Shell/CommandLine.cs b/Merlin/Main/Runtime/Microsoft.Scripting/Hosting/Shell/CommandLine.cs
index b758aae..e4bb717 100644
--- a/Merlin/Main/Runtime/Microsoft.Scripting/Hosting/Shell/CommandLine.cs
+++ b/Merlin/Main/Runtime/Microsoft.Scripting/Hosting/Shell/CommandLine.cs
@@ -327,8 +327,7 @@ namespace Microsoft.Scripting.Hosting.Shell {
return null;
}
- ExecuteCommand(_engine.CreateScriptSourceFromString(s,
- (s.Contains(Environment.NewLine))? SourceCodeKind.Statements : SourceCodeKind.InteractiveCode));
+ ExecuteCommand(_engine.CreateScriptSourceFromString(s, GetCodeKindForCode(s)));
return null;
}
@@ -379,12 +378,11 @@ namespace Microsoft.Scripting.Hosting.Shell {
bool allowIncompleteStatement = TreatAsBlankLine(line, autoIndentSize);
b.Append(line);
- b.Append("\n");
+ b.Append(Environment.NewLine);
string code = b.ToString();
- ScriptSource command = _engine.CreateScriptSourceFromString(code,
- (code.Contains(Environment.NewLine))? SourceCodeKind.Statements : SourceCodeKind.InteractiveCode);
+ ScriptSource command = _engine.CreateScriptSourceFromString(code, GetCodeKindForCode(code));
ScriptCodeParseResult props = command.GetCodeProperties(_engine.GetCompilerOptions(_scope));
if (SourceCodePropertiesUtils.IsCompleteOrInvalid(props, allowIncompleteStatement)) {
@@ -400,6 +398,13 @@ namespace Microsoft.Scripting.Hosting.Shell {
}
}
+ private static SourceCodeKind GetCodeKindForCode(string code)
+ {
+ return code.LastIndexOf(Environment.NewLine, Environment.NewLine.Length) > -1
+ ? SourceCodeKind.Statements
+ : SourceCodeKind.InteractiveCode;
+ }
+
/// <summary>
/// Gets the next level for auto-indentation
/// </summary>
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core