Skip to content

Commit

Permalink
Merge pull request #1757 from tigerbeetle/matklad/shellenv
Browse files Browse the repository at this point in the history
shell: properly propagate env vars
  • Loading branch information
matklad committed Mar 19, 2024
2 parents 9d4f0ac + eac343b commit e4f9df6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/shell.zig
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ pub fn exec_status_ok(shell: *Shell, comptime cmd: []const u8, cmd_args: anytype
.allocator = shell.gpa,
.argv = argv.slice(),
.cwd = cwd_path,
.env_map = &shell.env,
}) catch return false;
defer shell.gpa.free(res.stderr);
defer shell.gpa.free(res.stdout);
Expand Down Expand Up @@ -448,6 +449,7 @@ pub fn exec_stdout_options(
child.stdout_behavior = .Pipe;
child.stderr_behavior = .Pipe;
child.cwd = cwd_path;
child.env_map = &shell.env;

var stdout = std.ArrayList(u8).init(shell.gpa);
var stderr = std.ArrayList(u8).init(shell.gpa);
Expand Down Expand Up @@ -522,6 +524,7 @@ pub fn exec_raw(
.allocator = shell.arena.allocator(),
.argv = argv.slice(),
.cwd = cwd_path,
.env_map = &shell.env,
});
}

Expand Down Expand Up @@ -554,6 +557,7 @@ pub fn spawn_options(

var child = std.ChildProcess.init(argv.slice(), shell.gpa);
child.cwd = cwd_path;
child.env_map = &shell.env;
child.stdin_behavior = options.stdin_behavior;
child.stdout_behavior = .Pipe;
child.stderr_behavior = options.stderr_behavior;
Expand Down Expand Up @@ -585,6 +589,7 @@ pub fn zig(shell: Shell, comptime cmd: []const u8, cmd_args: anytype) !void {

var child = std.ChildProcess.init(argv.slice(), shell.gpa);
child.cwd = cwd_path;
child.env_map = &shell.env;
child.stdin_behavior = .Ignore;
child.stdout_behavior = .Inherit;
child.stderr_behavior = .Inherit;
Expand Down

0 comments on commit e4f9df6

Please sign in to comment.