WAD TEE adds newlines

May 20, 2008
12,171
133
Syracuse, NY, USA
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
 
May 20, 2008
12,171
133
Syracuse, NY, USA
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
 
May 20, 2008
12,171
133
Syracuse, NY, USA
WAD. TEE has always (for the past 25 years) appended a CR/LF at the end of the output. This is by request, and will not be changed.
What about the second behavior I mentioned when TEE produces nothing at all (console or file) if there are no newlines in stdout?
 

rconn

Administrator
Staff member
May 14, 2008
12,557
167
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).
 

Similar threads