diff options
author | Anton Kling <anton@kling.gg> | 2023-10-22 19:50:38 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-22 19:50:38 +0200 |
commit | 4e09bca9e34c226b6d7e34b4fa11248405fd988e (patch) | |
tree | 80f156b7940d9d19971395f335530170c69516c7 /userland/minibox/utilities/echo.c |
Move everything into a new repo.
Diffstat (limited to 'userland/minibox/utilities/echo.c')
-rw-r--r-- | userland/minibox/utilities/echo.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/userland/minibox/utilities/echo.c b/userland/minibox/utilities/echo.c new file mode 100644 index 0000000..5ec68a7 --- /dev/null +++ b/userland/minibox/utilities/echo.c @@ -0,0 +1,30 @@ +#include "include.h" +#include <fcntl.h> +#include <stdint.h> +#include <stdio.h> +#include <unistd.h> + +int echo(char **str, int new_line) { + for (; *str;) { + printf("%s", *str); + if (*++str) + putchar(' '); + } + + if (new_line) + putchar('\n'); + return 0; +} + +int echo_main(int argc, char **argv) { + int new_line = 1; + + for (; *++argv && '-' == **argv;) + switch (*(*argv + 1)) { + case 'n': + new_line = 0; + break; + } + + return echo(argv, new_line); +} |