The following code, on linux

```d
module runnable;
​
extern(C) int execv(const char* p, const char** args);
​
immutable src = `
    import std.getopt;
    void main(string[] args)
    {
        bool c;
        getopt(args, "c", &c);
    }
`;
​
void prepareProgram()
{
    import std.process  : execute;
    import std.file     : write;
    write("a.d", src);
    execute(["dmd", "a.d"]);
}
​
void main(string[] args)
{
    prepareProgram();
    execv("a", null);
}
```

results in a std.getopt exception:

object.Exception@/usr/include/dmd/phobos/std/getopt.d(423): Invalid arguments string passed: program name missing

Context is a program not written in D that uses execv to call a D program that uses getopt.

What do you think ?

Reply via email to