authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-24 02:41:45 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-24 02:41:45 -07:00
log0c3f8b1a010b345ad090eed5ba0e39b1ca7769e6
tree38c7dafbb83a260db3856bacb4a7221eea35962f
parent0869625fe5710d7b5f18977aae451405d9640934

util- add run_cmd_raw that returns the actual ChildProcess.ExecResult


1 files changed, 6 insertions(+), 2 deletions(-)

src/util/funcs.zig+6-2
...@@ -155,14 +155,18 @@ pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void {...@@ -155,14 +155,18 @@ pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void {
155 }155 }
156}156}
157157
158pub fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 {158pub fn run_cmd_raw(dir: ?[]const u8, args: []const []const u8) !std.ChildProcess.ExecResult {
159 const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) {159 return std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) {
160 error.FileNotFound => {160 error.FileNotFound => {
161 u.assert(false, "\"{s}\" command not found", .{args[0]});161 u.assert(false, "\"{s}\" command not found", .{args[0]});
162 unreachable;162 unreachable;
163 },163 },
164 else => return e,164 else => return e,
165 };165 };
166}
167
168pub fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 {
169 const result = try run_cmd_raw(dir, args);
166 gpa.free(result.stdout);170 gpa.free(result.stdout);
167 gpa.free(result.stderr);171 gpa.free(result.stderr);
168 return result.term.Exited;172 return result.term.Exited;