diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-08-23 20:20:11 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-08-23 20:20:11 +0200 |
| commit | ad628ed4f2f03fe3df8b5a0f2682b738d34d13ed (patch) | |
| tree | 57c3392d8bc875dcea6394fd25654315d753f300 | |
| parent | a1824752a0606ec1a4c4d995624133128cbac61a (diff) | |
| download | coreutils-ad628ed4f2f03fe3df8b5a0f2682b738d34d13ed.tar.gz coreutils-ad628ed4f2f03fe3df8b5a0f2682b738d34d13ed.tar.bz2 coreutils-ad628ed4f2f03fe3df8b5a0f2682b738d34d13ed.zip | |
Added yes (yes)
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | src/yes.c | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -11,6 +11,7 @@ Rewrite of some core utilities for educational purposes. | `tee` | read from standard input and write to standard output and files | | `shuf` | generate random permutations | | `echo` | display a line of text | +| `yes` | output a string repeatedly until killed | ## Pending diff --git a/src/yes.c b/src/yes.c new file mode 100644 index 0000000..9ae510c --- /dev/null +++ b/src/yes.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +int main(int argc, char **argv) +{ + while (true) + { + if (argc == 1) + fputs("y", stdout); + else + for (int i = 1; i < argc; i++) + { + fputs(argv[i], stdout); + if (i < argc - 1) + putchar(' '); + } + putchar('\n'); + } + return EXIT_SUCCESS; +} |
