lazysphere/command/yes.c
2023-05-15 10:57:33 -04:00

27 lines
506 B
C

#include "command.h"
#include "lslib.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_main) {
const char* repeat;
int i;
parse_help(argc, argv, help);
if (argc == 0) {
repeat = "y";
} else {
repeat = argv[0];
for (i = 1; i < argc; i++) {
*(argv[i]-1) = ' ';
}
}
while (true) {
printf("%s\n", repeat);
}
}