Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement environment variable passing for Process on Win32. Closes #790
. Closes #792
- Loading branch information
1 parent
ccf0b80
commit 434853a
Showing
2 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import os/Process, structs/HashMap | ||
|
||
p := Process new(["bash", "-c", "echo $MYVAR"]) | ||
main: func { | ||
env := HashMap<String, String> new() | ||
env put("MYVAR", "42") | ||
|
||
env := HashMap<String, String> new() | ||
env put("MYVAR", "42") | ||
p setEnv(env) | ||
command := ["bash", "-c", "echo $MYVAR"] | ||
version (windows) { | ||
command = ["cmd", "/c", "echo %MYVAR%"] | ||
} | ||
|
||
p execute() | ||
output := p getOutput() | ||
p := Process new(command) | ||
p setEnv(env) | ||
p execute() | ||
output := p getOutput() | ||
output = output trim() | ||
if (output != "42") { | ||
"Fail! expected output = 42, but got #{output}" println() | ||
exit(1) | ||
} | ||
|
||
"output = %s" printfln(output) | ||
"Pass" println() | ||
} |