Add -n flag to echo

This commit is contained in:
call-cc 2020-06-03 00:32:38 -04:00
parent 79ec3add72
commit 2214494a77
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}