digitalmars.D.learn - Reading stdin in Windows 7
- Stanislav Blinov (29/29) Aug 17 2010 Hello,
- Jesse Phillips (2/40) Aug 18 2010 In my experience Windows hasn't gotten piping right. And it has been kno...
- Stanislav Blinov (4/5) Aug 19 2010 Thanks, I'll take a look at that.
- Adam Wall (3/13) Nov 14 2010 Produces the following result:
Hello,
I'm receiving strange results with reading stdin on Windows 7. Consider
this code:
module test;
import std.stdio;
void main(string[] args)
{
foreach (int i, string line; lines(stdin))
{
write(line);
}
}
On Linux, if I do 'cat test.d | ./test' I get test.d contents on stdout.
But on Windows 7, ('type test.d | ./test.exe') the output is this:
std.stdio.StdioException: Bad file descriptor
module test;
import std.stdio;
void main(string[] args)
{
foreach (int i, string line; lines(stdin))
{
writef(line);
}
}
So I too get type.d contents on stdout, but preceeded by StdioException
string. This happens with dmd 2.047 and 2.048.
Is this my error, dmd's, or Windows's piping?
--
Aug 17 2010
Stanislav Blinov Wrote:
Hello,
I'm receiving strange results with reading stdin on Windows 7. Consider
this code:
module test;
import std.stdio;
void main(string[] args)
{
foreach (int i, string line; lines(stdin))
{
write(line);
}
}
On Linux, if I do 'cat test.d | ./test' I get test.d contents on stdout.
But on Windows 7, ('type test.d | ./test.exe') the output is this:
std.stdio.StdioException: Bad file descriptor
module test;
import std.stdio;
void main(string[] args)
{
foreach (int i, string line; lines(stdin))
{
writef(line);
}
}
So I too get type.d contents on stdout, but preceeded by StdioException
string. This happens with dmd 2.047 and 2.048.
Is this my error, dmd's, or Windows's piping?
--
In my experience Windows hasn't gotten piping right. And it has been known to
have bugs, this might be related:
http://stackoverflow.com/questions/466801/python-piping-on-windows-why-does-this-not-work
Aug 18 2010
18.08.2010 17:54, Jesse Phillips wrote:In my experience Windows hasn't gotten piping right. And it has been known to have bugs, this might be related: http://stackoverflow.com/questions/466801/python-piping-on-windows-why-does-this-not-workThanks, I'll take a look at that. --
Aug 19 2010
I experience the exact same problem on Windows 7 64-bit.import std.stdio; int main() { char[] buf; while (stdin.readln(buf)) write(buf); return 0; }If compiled as "test.exe", running the following command:echo "test line 1" | testProduces the following result:std.stdio.StdioException: Bad file descriptor "test line 1"
Nov 14 2010









Stanislav Blinov <blinov loniir.ru> 