summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index c989a35..ea34f19 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" };
+const BUILTINS = [_][]const u8{ "exit", "echo", "type", "pwd" };
pub const CommandResult = enum {
continue_loop,
@@ -27,6 +27,12 @@ pub fn executeEcho(stdout: anytype, args: ?[]const u8) !void {
}
}
+pub fn executePwd(allocator: std.mem.Allocator, stdout: anytype) !void {
+ const cwd = try std.fs.cwd().realpathAlloc(allocator, ".");
+ defer allocator.free(cwd);
+ try stdout.print("{s}\n", .{cwd});
+}
+
pub fn executeType(allocator: std.mem.Allocator, stdout: anytype, args: ?[]const u8) !void {
if (args) |a| {
if (isBuiltin(a)) {