mpw-tools/Echo.c
Kelvin Sherlock 37a3d2acd4 Echo command.
2015-11-28 12:06:01 -05:00

29 lines
401 B
C

#include <stdio.h>
/*
* Echo [-n] ...
*/
int main(int argc, char **argv) {
int i;
int space = 0;
int n = 0;
for (i = 1; i < argc; ++i) {
char *cp = argv[i];
if (cp[0] == '-' && cp[1] == 'n' && cp[2] == 0) {
n = 1;
continue;
}
if (space) fputc(' ', stdout);
fputs(cp, stdout);
space = 1;
}
if (space && n) fputc(' ', stdout);
if (!n) fputc('\n', stdout);
return 0;
}