]> pd.if.org Git - pdutils/commitdiff
implementation of echo
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 19 Oct 2013 13:51:04 +0000 (13:51 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 19 Oct 2013 13:51:04 +0000 (13:51 +0000)
utils/echo/Makefile [new file with mode: 0644]
utils/echo/echo.c [new file with mode: 0644]

diff --git a/utils/echo/Makefile b/utils/echo/Makefile
new file mode 100644 (file)
index 0000000..f1f3a63
--- /dev/null
@@ -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 (file)
index 0000000..1c22080
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+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);
+}