diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-31 17:19:29 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-31 17:19:29 +0000 |
| commit | 69f876b91df1ccb9c7bedfd145d6688bd5c87387 (patch) | |
| tree | 7f238cc690f98843fdbf12ae8d46e5b7e53de68b /src | |
| parent | 0a604ad5552d35372a05cf09a7fdf66d3cdc69e7 (diff) | |
| download | shell-zig-master.tar.gz shell-zig-master.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/builtins.zig | 4 | ||||
| -rw-r--r-- | src/executor.zig | 2 | ||||
| -rw-r--r-- | src/shell.zig | 5 |
3 files changed, 10 insertions, 1 deletions
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; |