summaryrefslogtreecommitdiff
path: root/src/cmd/echo
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/echo')
-rw-r--r--src/cmd/echo/echo.c17
-rw-r--r--src/cmd/echo/makefile10
2 files changed, 27 insertions, 0 deletions
diff --git a/src/cmd/echo/echo.c b/src/cmd/echo/echo.c
new file mode 100644
index 0000000..4733830
--- /dev/null
+++ b/src/cmd/echo/echo.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+ int i, nflag = 0;
+ argc--;
+
+ for (i = 1; i <= argc; i++) {
+ if (strcmp(argv[i], "-n") == 0)
+ nflag++;
+ else
+ printf("%s%c", argv[i], (i == argc) ? ((nflag == 1) ? '\0' : '\n') : ' ');
+ }
+ return 0;
+}
diff --git a/src/cmd/echo/makefile b/src/cmd/echo/makefile
new file mode 100644
index 0000000..0301f23
--- /dev/null
+++ b/src/cmd/echo/makefile
@@ -0,0 +1,10 @@
+all: echo
+ @cp echo $(PROROOT)/build/bin/echo
+
+echo: echo.c
+ $(CC) -o echo echo.c
+
+clean:
+ @rm -r echo
+
+.PHONY: all clean \ No newline at end of file