2023-05-06 04:39:44 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "lslib.h"
|
2023-04-27 18:38:16 +00:00
|
|
|
|
2023-05-01 22:43:32 +00:00
|
|
|
static void help(void) {
|
2023-04-27 18:38:16 +00:00
|
|
|
printf("Usage: yes [STRING]\n\n");
|
|
|
|
printf("Repeatedly output a line with all specified STRING(s), or 'y'.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
COMMAND(yes) {
|
2023-05-04 20:10:37 +00:00
|
|
|
const char* repeat;
|
|
|
|
int i;
|
2023-05-01 22:43:32 +00:00
|
|
|
|
|
|
|
parse_help(argc, argv, help);
|
|
|
|
|
2023-04-27 18:38:16 +00:00
|
|
|
if (argc == 0) {
|
|
|
|
repeat = "y";
|
|
|
|
} else {
|
|
|
|
repeat = argv[0];
|
2023-05-04 20:10:37 +00:00
|
|
|
for (i = 1; i < argc; i++) {
|
2023-04-27 18:38:16 +00:00
|
|
|
*(argv[i]-1) = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
printf("%s\n", repeat);
|
|
|
|
}
|
|
|
|
}
|