lazysphere/src/commands/yes.c

27 lines
533 B
C
Raw Normal View History

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