logicminds / rubyipmi

Command line wrapper for ipmitool and freeipmi
GNU Lesser General Public License v2.1
35 stars 32 forks source link

Fixes "NoMethodError: undefined method `success?' for nil:NilClass" #30

Closed bdunne closed 8 years ago

bdunne commented 8 years ago

Some ruby versions need to require 'English' otherwise $CHILD_STATUS is nil

bdunne commented 8 years ago

@logicminds I introduced this bug yesterday in https://github.com/logicminds/rubyipmi/pull/29

logicminds commented 8 years ago

What was the code that created this issue? I have never need this before?

bdunne commented 8 years ago

Rubocop suggested a change from $? to $CHILD_STATUS. Running any command looks at the return code. I'm on ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

logicminds commented 8 years ago

would need to check if 1.9.3+ supports this.

bdunne commented 8 years ago

Yes, this appears to be a ruby 1.9.3+ thing. I just switched to 1.9.3 and verified that it works there.

irb(main):001:0> `true`
=> ""
irb(main):002:0> $?
=> #<Process::Status: pid 6497 exit 0>
irb(main):003:0> $CHILD_STATUS
=> nil
irb(main):004:0> require "English"
=> true
irb(main):005:0> $CHILD_STATUS
=> #<Process::Status: pid 6497 exit 0>
irb(main):006:0> RUBY_VERSION
=> "1.9.3"
logicminds commented 8 years ago

I would prefer to go back to original $?. Seems silly that we need to require another file just to use something that should be built into ruby core.

bdunne commented 8 years ago

Switched back to $? and added to the ignore list