Skip to content

Commit

Permalink
Merge pull request #1 from xhyrom-forks/fix/return-correct-exit-code
Browse files Browse the repository at this point in the history
  • Loading branch information
trnxdev authored Aug 22, 2023
2 parents 6c79870 + 4041c7c commit 05d22c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/utils.zig
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 0 additions & 1 deletion zigd.ver

This file was deleted.

0 comments on commit 05d22c4

Please sign in to comment.