micro-utils/coreutils/yes.c

25 lines
407 B
C
Raw Permalink Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
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);
}
}