[comp.os.minix] MINIX1.2 tee-command fix

usenet@cps3xx.UUCP (Usenet file owner) (02/21/89)

MINIX 1.2 (640K) is being used to teach the OS course. We found a problem
with the 'tee' command. It doesn't function properly, if no appending to
an existing file is desired it overwrites the begining of the file.

$ echo one | tee jnk
one
$ echo two | tee -a jnk
two
$ echo three | tee -a jnk
three
$cat jnk
one
two
three
$ echo four | tee jnk
four
$ cat jnk
four
wo
three

We have fixed the problem, the cdiffs are given below for file
commands/tee.c. The file has to be recompiled and 'tee' should be
installed in /usr/bin.

-- ishwar rattan (rattan@frith.egr.msu.edu)
-------------------------------------------------------------------------
*** tee.c.old ***
--- tee.c ---
*** 38 - 46 ***
	if ((fd[s] = open (*argv, 2)) < 0 &&

--- 38 - 50 ---
	if (aflag)
	   fd[s] = open(*argv, 2);
	else {
	   fd[s] = creat(*argv, 0666);
	   if (fd[s] == -1) {
		std_err("Cannot open output file: ");
		std_err(*argv);
		std_err("\n");
		exit(2);
	   }
	}
	s++
    }
---------------------------------------------------------------------------