Why doesn't CTRL-D send EOF in mono?
Take the following C# file, the simplest possible repro of my problem:
using System;
using System.IO;
public static class Test
{
public static void Main(string[] args)
{
string line;
while ((line = Console.In.ReadLine()) != null)
{
Console.Out.WriteLine(line);
}
}
}
When I build this under mono and run it on the console, everything works fine except that I can't send EOF. Typing CTRL-D just puts a weird character on the command line. I think that I'm checking for EOF the wrong way, but Console.In
is a TextReader
, which doesn'开发者_运维问答t have the EndOfFile
property. How can I fix this?
Which version of mono? I fixed that problem in r129444 in 2009-03-16... Your program runs as expected when I press Ctrl-D.
Update: Nice. I found out that 2.4.x.y versions don't have the fix :-(. It will be in the upcoming 2.6 version... Sorry about that. Update 2: mono-2-4 was branched on 2009-03-13. I missed it by 3 days!
CTRL-D is the unix style end of file... because Mono derives from the Microsoft realm does it perhaps use CTRL-Z? (I don't have Mono installed, so I'm taking a shot in the dark here).
精彩评论