This commit is contained in:
Dominic Grimm 2025-06-19 16:55:59 +02:00
commit 184645ba63
Signed by: dergrimm
SSH key fingerprint: SHA256:0uoWpcqOtkyvQ+ZqBjNYiDqIZY+9s8VeZkkJ/4ryB4E
73 changed files with 4983 additions and 0 deletions

View file

@ -0,0 +1,31 @@
//! Capture stdout and write it into the <file>.
//! Usage: capture_out <file> <command> [args...]
const std = @import("std");
pub fn main() !void {
const allocator = std.heap.page_allocator;
var arg_iter = std.process.args();
defer arg_iter.deinit();
_ = arg_iter.next();
const outpath = arg_iter.next() orelse unreachable;
var args = std.ArrayList([]const u8).init(allocator);
defer args.deinit();
while (arg_iter.next()) |arg| try args.append(arg);
const res = try std.process.Child.run(.{
.allocator = allocator,
.argv = args.items,
.max_output_bytes = std.math.maxInt(usize),
});
var out = try std.fs.cwd().createFile(outpath, .{});
defer out.close();
try out.writeAll(res.stdout);
try std.io.getStdErr().writer().writeAll(res.stderr);
std.process.exit(res.term.Exited);
}