25 lines
478 B
C
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);
|
|
}
|
|
}
|