Skip to content

Commit 05d22c4

Browse files
authored
Merge pull request #1 from xhyrom-forks/fix/return-correct-exit-code
2 parents 6c79870 + 4041c7c commit 05d22c4

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/main.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ pub fn main() !void {
9595

9696
defer allocator.free(zig_binary);
9797

98-
try exec(allocator, zig_binary, args);
98+
const term = try exec(allocator, zig_binary, args);
99+
std.os.exit(term.Exited);
99100
}
100101

101-
fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !void {
102+
fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !std.ChildProcess.Term {
102103
var nargs = std.ArrayList([]const u8).init(allocator);
103104
defer nargs.deinit();
104105
try nargs.append(zig_binary);
@@ -109,7 +110,7 @@ fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !v
109110

110111
var naargs = try nargs.toOwnedSlice();
111112
defer allocator.free(naargs);
112-
_ = try run(allocator, naargs);
113+
return try run(allocator, naargs);
113114
}
114115

115116
// if user is in /home/john/dummy/x and there is a entry for /home/john/dummy/ in the config file,

src/utils.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const std = @import("std");
22

3-
pub fn run(allocator: std.mem.Allocator, argv: []const []const u8) !void {
3+
pub fn run(allocator: std.mem.Allocator, argv: []const []const u8) !std.ChildProcess.Term {
44
var proc = std.ChildProcess.init(argv, allocator);
5-
try proc.spawn();
6-
_ = try proc.wait();
5+
return proc.spawnAndWait();
76
}
87

98
pub fn fromHome(home: []const u8, to: []const u8) !std.fs.Dir {

zigd.ver

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)