Project

General

Profile

Bug #5728

SystemExit.new(bool, message)

Added by akr (Akira Tanaka) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
-
Backport:
[ruby-dev:44951]

Description

I found SystemExit.new doesn't take a bool as exit status:

It works well if an integer is given for status.

% ./ruby -e 'SystemExit.new(0, "msg")'
% ./ruby -e 'SystemExit.new(1, "msg")'

But it doesn't work if the status is a bool.

% ./ruby -e 'SystemExit.new(true, "msg")'
-e:1:in initialize': wrong number of arguments (2 for 0..1) (ArgumentError)
from -e:1:in
initialize'
from -e:1:in new'
from -e:1:in
'
% ./ruby -e 'SystemExit.new(false, "msg")'
-e:1:in initialize': wrong number of arguments (2 for 0..1) (ArgumentError)
from -e:1:in
initialize'
from -e:1:in new'
from -e:1:in
'

% ./ruby -v
ruby 2.0.0dev (2011-12-08 trunk 33981) [x86_64-linux]

I think SystemExit.new should accept a bool.


Files

system-exit-bool.patch (1.56 KB) system-exit-bool.patch akr (Akira Tanaka), 12/11/2011 02:24 AM

Associated revisions

Revision ea82d480
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Revision 34008
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

History

Updated by kosaki (Motohiro KOSAKI) over 7 years ago

I think SystemExit.new should accept a bool.

We have two choice and both are a lot of confusable.

1) true => EXIT_SUCCESS, false => EXIT_FAILURE
People may dislike it becuase true mapped 0 and false mapped 1.
2) true => EXIT_FAILURE, false => EXIT_SUCCESS
People also may dislike it. Because true usually isn't used for failure.

As far as EXIT_SUCCESS==0, I doubt we can make natural conversion.

#2

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

=begin
I don't think we have two.

The latter choice is not acceptable, since the return value of (({Kernel#system})) and the first argument of (({Kernel#exit})) are same as the former.

And should not assume (({EXIT_SUCCESS})) to be 0.
=end

Updated by akr (Akira Tanaka) over 7 years ago

  • ruby -v changed from ruby 2.0.0dev (2011-12-08 trunk 33981) [x86_64-linux] to -

2011/12/8 Nobuyoshi Nakada nobu@ruby-lang.org:

I don't think we have two.

The latter choice is not acceptable, since the return value of (({Kernel#system})) and the first argument of (({Kernel#exit})) are same as the former.

And should not assume (({EXIT_SUCCESS})) to be 0.

Agreed.

In addition, if this issue (#5728) and
Process::EXIT_SUCCESS/Process::EXIT_FAILIURE issue (#5726) are both rejected,
it is very diffcult to use SystemExit.new for EXIT_FAILURE.
--
Tanaka Akira

Updated by kosaki (Motohiro KOSAKI) over 7 years ago

I don't think we have two.

The latter choice is not acceptable, since the return value of (({Kernel#system})) and the first argument of (({Kernel#exit})) are same as the former.

And should not assume (({EXIT_SUCCESS})) to be 0.

Agreed.

In addition, if this issue (#5728) and
Process::EXIT_SUCCESS/Process::EXIT_FAILIURE issue (#5726) are both rejected,
it is very diffcult to use SystemExit.new for EXIT_FAILURE.

I overlooked Kernel#exit. then I withdraw my argument. Thank you
for clarification. But, I'm still bit worry about confusable thing because
a lot of people know EXIT_SUCCESS==0 on their platform. so please
write a doc true convert to EXIT_SUCCES, and not 1 clearly.

Thank you.

#6

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34008.
Akira, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • error.c (exit_initialize): deal with true and false as well as Kernel#exit. [ruby-dev:44951] [Bug #5728]

Also available in: Atom PDF