On Wed, Dec 05, 2001 at 04:11:45AM +0900, Vincent Foley wrote:
> OK, help me here.  Here's a small piece of code:
> [code]
> 
> #!/usr/bin/env ruby
> 
> phrase = gets.chomp
> 
> l = phrase.length
> 
> l.downto(0) {|x|
>   print phrase[x,1]
> }
> #puts
> [/code]
> 
> Notice that 'puts' on the last line is commented.  If I leave it
> commented, nothing will output, if I uncomment it, then my string will
> be displayed.  Anyone could enlighten me?
> 


Nothing is flushing your output stream, thus your script
ends with the phrase still in the output stream but doesn't
come to flush it. Try to redirect the script's output to
a file and watch how it gets flushed then. I'm not sure if
that's a bug in ruby, I have experienced this several times
before, too.

Ah some tests show that it's shell-specific, my zsh eats
the line and doesn't flush the output, my (t)csh does.

Martin Weber