[TxMt] Line buffering for the Stdout window?

Jean-Denis Muys jdmuys at free.fr
Fri Apr 10 07:43:27 UTC 2009


Hello,

I'm growing increasingly annoyed with an issue I could not find a  
solution for: the output to stderr and stdout getting out of sync in  
the default TextMate output window.

I am currently developping for Perl, but I quickly checked that the  
issue is there for Ruby as well.

If you run this little Perl program:


print "line 1\n";
warn "line 2\n";
print "line 3\n";
warn "line 4\n";
print "line 5\n";

You get this output:

line 2
line 4
line 1
line 3
line 5

This is the wrong behaviour because STDOUT is supposed to be line- 
buffered ("hot" in Perl lingo) when going to a terminal. So OK, the TM  
output Window is incorrectly *not* considered as a terminal. This  
should be fixable by any of the following three standard idioms:


# fix 1
my $previous  = select STDOUT;
$|=1;
select $previous;

# fix 2
binmode(STDOUT, ":unix");

# fix 3
STDOUT->autoflush(1);

But none of them work.

This Ruby program exhibits the same problem:

$stdout.puts "line 1\n";
$stderr.puts "line 2\n"
$stdout.puts "line 3\n";
$stderr.puts "line 4\n"
$stdout.puts "line 5\n";


Has anybody been able to find a solution for this? This is a PITA.

Many thanks.

Jean-Denis




More information about the textmate mailing list