From 69f876b91df1ccb9c7bedfd145d6688bd5c87387 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Tue, 31 Mar 2026 14:19:29 -0300 Subject: feat: jobs builtin --- src/builtins.zig | 4 +++- src/executor.zig | 2 ++ src/shell.zig | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/builtins.zig b/src/builtins.zig index 3608b81..bb84a45 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1,7 +1,7 @@ const std = @import("std"); const path = @import("path.zig"); -const BUILTINS = [_][]const u8{ "exit", "echo", "type", "pwd", "cd", "history" }; +const BUILTINS = [_][]const u8{ "exit", "echo", "type", "pwd", "cd", "history", "jobs" }; pub const CommandResult = enum { continue_loop, exit_shell }; @@ -12,6 +12,8 @@ pub inline fn isBuiltin(cmd_name: []const u8) bool { return false; } +pub inline fn executeJobs() void {} + pub inline fn executeExit() CommandResult { return .exit_shell; } diff --git a/src/executor.zig b/src/executor.zig index f776e74..073c962 100644 --- a/src/executor.zig +++ b/src/executor.zig @@ -128,6 +128,8 @@ fn runBuiltinInChild( builtins.executePwd(allocator, w) catch {}; } else if (std.mem.eql(u8, cmd_name, "cd")) { builtins.executeCd(allocator, w, args) catch {}; + } else if (std.mem.eql(u8, cmd_name, "jobs")) { + builtins.executeJobs(); } else if (std.mem.eql(u8, cmd_name, "exit")) { // exit inside pipeline child just exits child } diff --git a/src/shell.zig b/src/shell.zig index d3f75ec..142ea47 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -149,6 +149,11 @@ pub fn executeCommand( return .continue_loop; } + if (std.mem.eql(u8, cmd_name, "jobs")) { + builtins.executeJobs(); + return .continue_loop; + } + if (std.mem.eql(u8, cmd_name, "type")) { try builtins.executeType(allocator, stdout, args); return .continue_loop; -- cgit v1.2.3