bug? ruby doesn't flush stdio on exit!

S

Sam Roberts

This can't be a feature... stdio should flush on exit!

% ruby -e 'printf "hello"'
% ruby -e 'printf "hello\n"'
hello
% ruby -e 'printf "hello";puts "hi";'
hellohi
%

Sam
 
A

Aredridel

This can't be a feature... stdio should flush on exit!

% ruby -e 'printf "hello"'
% ruby -e 'printf "hello\n"'
hello
% ruby -e 'printf "hello";puts "hi";'
hellohi
%

In the first example, your shell is overwriting the output.

Not a bug.
 
S

Sam Roberts

Quoting (e-mail address removed), on Thu, Mar 17, 2005 at 10:38:26AM +0900:
In the first example, your shell is overwriting the output.

You're right, thanks!

And I'm pretty surprised.
Not a bug.

I think it is - a bug in zsh.

start with bash:

[ensemble] ~/p/ruby/zeroconf $ ruby -e 'print "hello"'
hello[ensemble] ~/p/ruby/zeroconf $ zsh
ensemble% ruby -e 'printf "hello"'
ensemble%


I think zsh is wrong here..

Cheers,
Sam
 
L

Lloyd Zusman

Sam Roberts said:
This can't be a feature... stdio should flush on exit!

% ruby -e 'printf "hello"'
% ruby -e 'printf "hello\n"'
hello
% ruby -e 'printf "hello";puts "hi";'
hellohi
%

It does flush. Try doing this:

% ruby -e 'printf "hello"'; echo ''
hello

What's going on is that your shell is overwriting the "hello" that
indeed gets written on the next line, when it repositions the cursor to
the left column. Adding the "; echo ''" to the end shows that this is
taking place.
 
J

Jos Backus

Also, check out

setopt nopromptcr

in the zsh docs.

hal:~% setopt promptcr # default
hal:~% echo -n hi
hal:~% setopt nopromptcr
hal:~% echo -n hi
hihal:~%
 
N

Navindra Umanee

Aredridel said:
In the first example, your shell is overwriting the output.

Not a bug.

How did you diagnose his problem, out of curiosity?

Cheers,
Navin.
 
S

Sam Roberts

Quoting (e-mail address removed), on Thu, Mar 17, 2005 at 11:35:01AM +0900:
Also, check out

setopt nopromptcr

in the zsh docs.

Great! zsh hasn't let me down until now, I'm glad I can fix this.

Sam
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: bug? ruby doesn't flush stdio on exit!"

|> In the first example, your shell is overwriting the output.
|> Not a bug.
|
|How did you diagnose his problem, out of curiosity?

I guess he had same experience, like myself.

matz.
 
R

Robert Klemme

Sam Roberts said:
Quoting (e-mail address removed), on Thu, Mar 17, 2005 at 10:38:26AM +0900:
In the first example, your shell is overwriting the output.

You're right, thanks!

And I'm pretty surprised.
Not a bug.

I think it is - a bug in zsh.

start with bash:

[ensemble] ~/p/ruby/zeroconf $ ruby -e 'print "hello"'
hello[ensemble] ~/p/ruby/zeroconf $ zsh
ensemble% ruby -e 'printf "hello"'
ensemble%


I think zsh is wrong here..

It's probably just the promt setting. If the prompt starts with a CR then
old content of the line is overwritten.

robert
 
N

Nikolai Weibull

* Robert Klemme (Mar 17, 2005 10:10):
I think it is - a bug in zsh.

start with bash:

[ensemble] ~/p/ruby/zeroconf $ ruby -e 'print "hello"'
hello[ensemble] ~/p/ruby/zeroconf $ zsh
ensemble% ruby -e 'printf "hello"'
ensemble%


I think zsh is wrong here..

Wow, amazing how everything is a bug. Bugs, bugs, bugs...Bugs
everywhere!
It's probably just the promt setting. If the prompt starts with a CR then
old content of the line is overwritten.

Precisely. Zsh must know where it begins printing the prompt (and its
absolute width) to know when it has reached the right end of the
terminal (so that it can do proper wrapping or shifting). There's a
promptcr module for Zsh that outputs a newline before printing the
prompt, thus output is never overwritten. It's not very good, though.

See http://rubyurl.com/InP9S for a discussion on an alternative solution
to using promptcr,
nikolai
 
N

Nikolai Weibull

* Nikolai Weibull (Mar 17, 2005 10:25):
… There's a promptcr module for Zsh that outputs a newline before
printing the prompt, thus output is never overwritten. …

Actually, it's called promptnl, not promptcr; sorry,
nikolai
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top