commit 2214494a7793958383a4992ce057a1898bc1c9f2
parent 79ec3add7294af15483217f7d543c8b59f1facc1
Author: call-cc <callcc@vxempire.xyz>
Date: Wed, 3 Jun 2020 00:32:38 -0400
Add -n flag to echo
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/echo.c b/src/echo.c
@@ -1,13 +1,17 @@
#include <stdio.h>
+#include <string.h>
int
main(int argc, char *argv[])
{
+ int nflag;
+ if(strcmp(argv[1], "-n") == 0)
+ nflag = 1;
++argv;
while(*argv) {
(void)fputs(*argv, stdout); // Print argv
if(*++argv) putchar(' '); // If multiple things in argv, print a space between them.
}
- putchar('\n');
+ if(nflag) putchar('\n');
return 0;
}