From 19b58e85cfc5173ede740ca49d5e44deb34cbce8 Mon Sep 17 00:00:00 2001 From: ciao Date: Tue, 15 Apr 2025 21:34:11 +0800 Subject: [PATCH] feat: implement yes command --- build.zig | 6 ++++++ src/yes/main.cpp | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/yes/main.cpp diff --git a/build.zig b/build.zig index ce9c3e5..b9685ed 100644 --- a/build.zig +++ b/build.zig @@ -73,5 +73,11 @@ pub fn build(b: *std.Build) void { "src/false", }).build(b, optimize, target, &targets); + Executable.init("yes", &[_][]const u8{ + "src/yes/main.cpp", + }, &[_][]const u8{ + "src/yes", + }).build(b, optimize, target, &targets); + zcc.createStep(b, "cdb", targets.toOwnedSlice() catch @panic("OOM")); } diff --git a/src/yes/main.cpp b/src/yes/main.cpp new file mode 100644 index 0000000..7d51ca6 --- /dev/null +++ b/src/yes/main.cpp @@ -0,0 +1,20 @@ +#include +#include + +int main(int argc, char *argv[]) { + std::string output = ""; + if (argc > 1) { + for (int i = 1; i < argc; ++i) { + output += argv[i]; + if (i < argc - 1) { + output += " "; + } + } + } else { + output = "y"; + } + while (true) { + std::cout << output << '\n'; + } + return 0; +}