diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-06 00:39:44 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-06 00:39:44 -0400 |
commit | d8f2c10b7108fff6b7e437291093a1cadc15ab9f (patch) | |
tree | 3fc50a19d6fbb9c94a8fe147cd2a6c4ba7f59b8d /command/yes.c | |
parent | ansii c (diff) | |
download | lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.tar.gz lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.tar.bz2 lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.zip |
refactor
Diffstat (limited to 'command/yes.c')
-rw-r--r-- | command/yes.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/command/yes.c b/command/yes.c new file mode 100644 index 0000000..f979a9f --- /dev/null +++ b/command/yes.c @@ -0,0 +1,27 @@ +#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) { + 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); + } +} |