summaryrefslogtreecommitdiff
path: root/src/cmd/echo/echo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/echo/echo.c')
-rw-r--r--src/cmd/echo/echo.c17
1 files changed, 17 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;
+}