From 4041c7cfd47cb4925173dd90996ebc552c09db4a Mon Sep 17 00:00:00 2001 From: xHyroM Date: Tue, 22 Aug 2023 08:23:11 +0200 Subject: [PATCH] fix: exit with correct exit code --- src/main.zig | 7 ++++--- src/utils.zig | 5 ++--- zigd.ver | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 zigd.ver diff --git a/src/main.zig b/src/main.zig index c740e8e..0685e83 100644 --- a/src/main.zig +++ b/src/main.zig @@ -95,10 +95,11 @@ pub fn main() !void { defer allocator.free(zig_binary); - try exec(allocator, zig_binary, args); + const term = try exec(allocator, zig_binary, args); + std.os.exit(term.Exited); } -fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !void { +fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !std.ChildProcess.Term { var nargs = std.ArrayList([]const u8).init(allocator); defer nargs.deinit(); try nargs.append(zig_binary); @@ -109,7 +110,7 @@ fn exec(allocator: std.mem.Allocator, zig_binary: []const u8, args: [][:0]u8) !v var naargs = try nargs.toOwnedSlice(); defer allocator.free(naargs); - _ = try run(allocator, naargs); + return try run(allocator, naargs); } // if user is in /home/john/dummy/x and there is a entry for /home/john/dummy/ in the config file, diff --git a/src/utils.zig b/src/utils.zig index 231df4a..cb8b333 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -1,9 +1,8 @@ const std = @import("std"); -pub fn run(allocator: std.mem.Allocator, argv: []const []const u8) !void { +pub fn run(allocator: std.mem.Allocator, argv: []const []const u8) !std.ChildProcess.Term { var proc = std.ChildProcess.init(argv, allocator); - try proc.spawn(); - _ = try proc.wait(); + return proc.spawnAndWait(); } pub fn fromHome(home: []const u8, to: []const u8) !std.fs.Dir { diff --git a/zigd.ver b/zigd.ver deleted file mode 100644 index 38431f5..0000000 --- a/zigd.ver +++ /dev/null @@ -1 +0,0 @@ -0.12.0-dev.140+e078324db \ No newline at end of file