Commit | Line | Data |
---|---|---|
77e25d77 WJ |
1 | /* |
2 | * This dumb little program emulates the System V "echo" command, | |
3 | * to accommodate BSD systems which don't understand the \c escape, | |
4 | * meaning don't echo a newline. BSD uses "echo -n". | |
5 | */ | |
6 | ||
7 | #include <stdio.h> | |
8 | ||
9 | int putnl; | |
10 | ||
11 | main(argc, argv) | |
12 | int argc; | |
13 | char *argv[]; | |
14 | { | |
15 | putnl = 1; | |
16 | while (--argc > 0) | |
17 | { | |
18 | vecho(*++argv); | |
19 | if (argc > 1) | |
20 | putchar(' '); | |
21 | } | |
22 | if (putnl) | |
23 | putchar('\n'); | |
24 | exit(0); | |
25 | } | |
26 | ||
27 | vecho(str) | |
28 | char *str; | |
29 | { | |
30 | register char *s; | |
31 | ||
32 | for (s = str; *s != '\0'; s++) | |
33 | { | |
34 | if (*s == '\\' && s[1] == 'c') | |
35 | { | |
36 | putnl = 0; | |
37 | return; | |
38 | } | |
39 | putchar(*s); | |
40 | } | |
41 | } |