WAD TEE adds newlines

#1
I used ECHOS because I don't want newlines in the console or in the file!
Code:
v:\> do forever ( delay 1 & echos foo | tee v:\foo.txt )
foo
foo
foo
foo
^C
v:\> do forever ( delay 1 & echos foo | tee /a v:\foo.txt )
foo
foo
foo
foo
^C
v:\> type foo.txt
foo
foo
foo
foo
foo
 
#2
In fact, TEE seems to depend on newlines. In the scenario below, I get no console output and nothing in the file!
Code:
v:\> type teetest.btm
do forever ( echos foo & delay 1 )

v:\> teetest.btm | tee /a teetest.txt
^C

Cancel batch job V:\teetest.btm ? (Y/N/A) : Y

v:\> type teetest.txt

v:\>
External TEEs do not have this problem.
Code:
v:\> do forever ( delay 1 & echos foo | g:\gnu\tee.exe -a v:\foo.txt )
foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo^C
v:\> type foo.txt
foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
 

rconn

Administrator
Staff member
May 14, 2008
10,532
94
#5
What about the second behavior I mentioned when TEE produces nothing at all (console or file) if there are no newlines in stdout?
Also WAD. TEE is calling a Windows API to get the next line from STDIN, and you're not giving it a line.

And no, that can't be changed to be character buffered instead, because (1) 99.999% of Windows console apps are line buffered (TCC is one of very, very few that aren't); and (2) it would be phenomenally slow (there's a reason for #1).