Workaround for 1.8.6 with CommandLine

J

Jim Freeze

Hello

If you are using ruby-1.8.6, you may have noticed a bug where exit
always
returns 0 when called from within an at_exit block. You can test this
on your
machine with the following little snippet:

ruby -e 'at_exit { exit(1) }' ; echo $?

The result should be '1', but ruby-1.8.6 will return '0'.

To workaround this when using commandline, you can change an application
that reads like:

require 'rubygems'
require 'commandline'
class App < CommandLine::Application
end

to

require 'rubygems'
require 'commandline'
class App < CommandLine::Application_wo_AutoRun
end
App.run

This will not use the at_exit technique of self launching the app and
give the correct
exit code.

Jim
 
A

ara.t.howard

Hello

If you are using ruby-1.8.6, you may have noticed a bug where exit always
returns 0 when called from within an at_exit block. You can test this on your
machine with the following little snippet:

ruby -e 'at_exit { exit(1) }' ; echo $?

The result should be '1', but ruby-1.8.6 will return '0'.

wow. i rely on that combination in a few places, in particular i dis-inherit
exit
handlers in child processes by doing this as the first line

at_exit{ exit! status }

do you know if it's a bug or new behaviour?

-a
 
A

ara.t.howard

It's a bug. Already fixed in 1.9, but I haven't heard anything about
applying the fix to 1.8 branch yet. Which is unfortunate, as it breaks quite
a few things.

thank you!

-a
 
N

Nobuyoshi Nakada

Hi,

At Sat, 31 Mar 2007 02:02:11 +0900,
Alexey Verkhovsky wrote in [ruby-talk:246032]:
It's a bug. Already fixed in 1.9, but I haven't heard anything about
applying the fix to 1.8 branch yet. Which is unfortunate, as it breaks quite
a few things.

It was fixed in 1.8, and doesn't exist in 1.9.
 

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,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top