From 266e932fd664ee803ca86f1d9cb029715f3f6b56 Mon Sep 17 00:00:00 2001 From: 8nlight <8nlight@disroot.org> Date: Tue, 3 Oct 2023 23:09:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?src=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/true.c | 3 +++ src/yes.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/true.c create mode 100644 src/yes.c diff --git a/src/true.c b/src/true.c new file mode 100644 index 0000000..061ed7e --- /dev/null +++ b/src/true.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/src/yes.c b/src/yes.c new file mode 100644 index 0000000..2e07bef --- /dev/null +++ b/src/yes.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +void print(const char *buf, ssize_t len) { + if (write(STDOUT_FILENO, buf, len) < 0) + exit(1); +} + +int main(const int argc, const char **argv) { + if (argc == 1) + while (1) + print("y\n", 2); + + while (1) { + for (ssize_t i = 1; i < argc; i++) { + print(argv[i], strlen(argv[i])); + print(" ", 1); + } + + print("\n", 1); + } +}