[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

bug? ruby doesn't flush stdio on exit!

Sam Roberts

3/17/2005 1:35:00 AM

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



10 Answers

Aredridel

3/17/2005 1:38:00 AM

0

On Thu, 17 Mar 2005 10:34:47 +0900, Sam Roberts <sroberts@uniserve.com> wrote:
> 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.


Sam Roberts

3/17/2005 1:44:00 AM

0

Quoting aredridel@gmail.com, on Thu, Mar 17, 2005 at 10:38:26AM +0900:
> On Thu, 17 Mar 2005 10:34:47 +0900, Sam Roberts <sroberts@uniserve.com> wrote:
> > 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.

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



Lloyd Zusman

3/17/2005 1:58:00 AM

0

Sam Roberts <sroberts@uniserve.com> writes:

> 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.


--
Lloyd Zusman
ljz@asfast.com
God bless you.



Jos Backus

3/17/2005 2:35:00 AM

0

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:~%

--
Jos Backus
jos at catnook.com


Navindra Umanee

3/17/2005 2:45:00 AM

0

Aredridel <aredridel@gmail.com> wrote:
> > 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.

How did you diagnose his problem, out of curiosity?

Cheers,
Navin.


Sam Roberts

3/17/2005 2:46:00 AM

0

Quoting jos@catnook.com, 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

> hal:~% setopt promptcr # default
> hal:~% echo -n hi
> hal:~% setopt nopromptcr
> hal:~% echo -n hi
> hihal:~%
>
> --
> Jos Backus
> jos at catnook.com
>


Yukihiro Matsumoto

3/17/2005 4:25:00 AM

0

Hi,

In message "Re: bug? ruby doesn't flush stdio on exit!"
on Thu, 17 Mar 2005 11:45:08 +0900, Navindra Umanee <navindra@cs.mcgill.ca> writes:

|> 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.


Robert Klemme

3/17/2005 8:57:00 AM

0


"Sam Roberts" <sroberts@uniserve.com> schrieb im Newsbeitrag
news:20050317014259.GA908@ensemble.local...
> Quoting aredridel@gmail.com, on Thu, Mar 17, 2005 at 10:38:26AM +0900:
> > On Thu, 17 Mar 2005 10:34:47 +0900, Sam Roberts
<sroberts@uniserve.com> wrote:
> > > 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.
>
> 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

Nikolai Weibull

3/17/2005 9:23:00 AM

0

* 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... for a discussion on an alternative solution
to using promptcr,
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Nikolai Weibull

3/17/2005 9:27:00 AM

0

* 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

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}