From: Nathan Wagner Date: Sat, 19 Oct 2013 13:51:04 +0000 (+0000) Subject: implementation of echo X-Git-Url: https://pd.if.org/git/?p=pdutils;a=commitdiff_plain;h=b6d847ae20c32744d508eced2be3132c3fa8c5b9 implementation of echo --- b6d847ae20c32744d508eced2be3132c3fa8c5b9 diff --git a/utils/echo/Makefile b/utils/echo/Makefile new file mode 100644 index 0000000..f1f3a63 --- /dev/null +++ b/utils/echo/Makefile @@ -0,0 +1,7 @@ +CFLAGS=-Wall + +echo: echo.c + $(CC) $(CFLAGS) -o $@ $+ + +echo.html: + wget http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html diff --git a/utils/echo/echo.c b/utils/echo/echo.c new file mode 100644 index 0000000..1c22080 --- /dev/null +++ b/utils/echo/echo.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int main(int ac, char *av[]) { + int nl = 1; + int as = 1; + int i; + + if (ac && !strcmp(av[1], "-n")) { + as++; + nl=0; + } + + for (i=as; i < ac; i++) { + printf("%s%s", i > as ? " " : "", av[i]); + } + + if (nl) printf("\n"); + + exit(0); +}