diff options
Diffstat (limited to 'src/cmd/pipe.zig')
-rw-r--r-- | src/cmd/pipe.zig | 11 |
1 files changed, 4 insertions, 7 deletions
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; } |