From 45342f7c098d0f89726111f99404bc6ac6613609 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Fri, 5 Dec 2025 05:52:03 -0300 Subject: codecrafters submit [skip ci] --- src/main.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index cc272ec..560ae60 100644 --- a/src/main.zig +++ b/src/main.zig @@ -456,4 +456,17 @@ pub fn main() !void { break; } } + + // Save history to HISTFILE on exit + if (std.posix.getenv("HISTFILE")) |histfile_path| { + const file = std.fs.cwd().createFile(histfile_path, .{}) catch null; + if (file) |f| { + defer f.close(); + + for (history.items) |cmd| { + _ = f.writeAll(cmd) catch {}; + _ = f.writeAll("\n") catch {}; + } + } + } } -- cgit v1.2.3