lazysphere/src/commands/yes.c
2023-05-01 18:43:32 -04:00

25 lines
478 B
C

#include "../command.h"
static void help(void) {
printf("Usage: yes [STRING]\n\n");
printf("Repeatedly output a line with all specified STRING(s), or 'y'.\n");
}
COMMAND(yes) {
parse_help(argc, argv, help);
const char* repeat;
if (argc == 0) {
repeat = "y";
} else {
repeat = argv[0];
for (int i = 1; i < argc; i++) {
*(argv[i]-1) = ' ';
}
}
while (true) {
printf("%s\n", repeat);
}
}