std.process.system and friends

Peter Sommerfeld noreply at rubrica.at
Sun Feb 3 11:05:00 PST 2013


    pathSeparator ~ path  ~ pathToMyDir   Ali Çehreli wrote:

> import std.process;
>
> void main()
> {
>      environment["MY_ENV_VAR"] = "42";
>
>      system("echo $MY_ENV_VAR");  // <-- prints "42"
>      assert(shell("echo $MY_ENV_VAR") == "42\n");
> }
>
> There is also 'setenv' in that module but I find 'environment' more  
> convenient. (Also, 'setenv' is evil because it has a bool parameter. ;))

Win7, dmd 2.061: environment seems to be read only.

string path = environment["PATH"];
// OK

environment("PATH"] = pathSeparator ~ path ~ pathToMyDir ;
// failed, unidentified identifier

setenv("PATH", pathSeparator ~ path  ~ pathToMyDir, true);
// failed, undefined identifier

Do you know a way to set it via system/shell calls, notably under windows?

Peter


More information about the Digitalmars-d-learn mailing list