1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WAD TEE adds newlines

Discussion in 'Support' started by vefatica, Oct 12, 2013.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    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
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    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.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    What about the second behavior I mentioned when TEE produces nothing at all (console or file) if there are no newlines in stdout?
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    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).
     

Share This Page