std.path.shell throws exception with garbage string

Andrej Mitrovic none at none.none
Wed Mar 9 15:55:07 PST 2011


import std.process;

void main()
{
    char[] chBuffer = new char[](256);
    chBuffer[] = '\0';
    chBuffer[0..3] = "dir".dup;
    
    auto result = shell(chBuffer.idup);
}

It does two things:
1. It prints out the result of the shell invocation to stdout. This shouldn't happen.

2. It throws this:
std.file.FileException at std\file.d(295): 5a5785b9a9ef300e292f021170a6bb2e34b80c86bb8decbb6b9b8d3b5e852cd

This sample works:
import std.process;

void main()
{
    string chBuffer = "dir";
    auto result = shell(chBuffer);
}

Here the shell invocation isn't printed to the screen, but stored in result  like it should be.

The problem is I'm working with the win32 API and I can't use lovely D strings. I've tried using to!string and .idup on the call to 'shell', I've tried appending null's to the char[] but nothing seems to help. What am I doing wrong?



More information about the Digitalmars-d-learn mailing list