From 6f84a9a1458ff053d6dc7c1a66c1e03deb8e8793 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 15 Aug 2025 13:43:22 +0200 Subject: CommandContext: Add execute_command back, properly typed. --- src/cmd/pipe.zig | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/cmd/pipe.zig') diff --git a/src/cmd/pipe.zig b/src/cmd/pipe.zig index ad0d0e4..39bee8c 100644 --- a/src/cmd/pipe.zig +++ b/src/cmd/pipe.zig @@ -11,15 +11,12 @@ const InputSource = types.InputSource; const cmd = @import("../cmd.zig"); const Command = cmd.Command; -// Function type for executing commands with output capture -const ExecuteCommandFn = *const fn (Command, Allocator, ?*OutputCapture, ?*InputSource) anyerror!CommandStatus; - pub const PipeCommand = struct { left: *Command, right: *Command, - pub fn eval(pipe: PipeCommand, ctx: CommandContext, executeCommandWithOutput: ExecuteCommandFn) !CommandStatus { - // Cast the execute function back to its proper type + pub fn eval(pipe: PipeCommand, ctx: CommandContext) !CommandStatus { + const execute_command = ctx.execute_command; const allocator = ctx.allocator; const output_capture = ctx.output_capture; @@ -28,7 +25,7 @@ pub const PipeCommand = struct { defer left_output.deinit(); // Execute the left command and capture its output - const left_status = try executeCommandWithOutput(pipe.left.*, allocator, &left_output, null); + const left_status = try execute_command(pipe.left.*, allocator, &left_output, null); // If the left command failed, return its status if (left_status != .Code or left_status.Code != 0) { @@ -40,7 +37,7 @@ pub const PipeCommand = struct { var right_input = InputSource.init(left_output_data); // Execute the right command with the left command's output as input - const right_status = try executeCommandWithOutput(pipe.right.*, allocator, output_capture, &right_input); + const right_status = try execute_command(pipe.right.*, allocator, output_capture, &right_input); return right_status; } -- cgit v1.2.1