1 /*-
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)tee.c 8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11
12 #include <stdio.h>
main()13 main()
14 {
15 int f, c;
16
17 f = creat(".ocopy", 0666);
18 while (read(0, &c, 1) == 1) {
19 write (1, &c, 1);
20 put(c, f);
21 }
22 fl(f);
23 close(f);
24 }
25
26 static char ln[BUFSIZ];
27 char *p = ln;
put(c,f)28 put(c, f)
29 {
30 *p++ = c;
31 if (c == '\n') {
32 fl(f);
33 p=ln;
34 }
35 }
fl(f)36 fl(f)
37 {
38 register char *s;
39
40 s = ln;
41 while (*s == '$' && *(s+1) == ' ')
42 s += 2;
43 write(f, s, p-s);
44 }
45