Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$CHILD_STATUS is nil in some Ruby versions without require "English" #28

Closed
aufflick opened this issue Aug 12, 2014 · 5 comments
Closed

Comments

@aufflick
Copy link

See CocoaPods/CocoaPods#2225

This causes ref_exists? to always return false.

I don't know why it doesn't cause other issues elsewhere, but the nicely named $CHILD_STATUS global var in ruby 1.9 and later (or something, not exactly sure of the circumstances). It's fixed if you replace $CHILD_STATUS with the timeless $? or place require "English" at the top of git.rb (although that may introduce a new ruby version dependency, I'm not familiar with when it was introduced).

@aufflick
Copy link
Author

@fabiopelosin are you sure .to_i is required? A big downside to that approach is that if the symbol is nil (eg. when $CHILD_STATUS does not exist as a variable) then .to_i will return zero and thus indicate success.

§ ruby -e "print nil.to_i == 0 ? 'yes' : 'no'"
yes
§ ruby -e 'print $FLUBBER.to_i == 0 ? "yes" : "no"'
yes

If you do need to force to integer for comparison you should probably check for nil first also. I know

@fabiopelosin
Copy link
Member

@aufflick Thanks... I added the .to_i expecting to raise a no method error in case of nil... actually I've read about this behavior but it was completely lost in the inners of my mind.

I will fix it... thanks!

@alloy
Copy link
Member

alloy commented Aug 18, 2014

@fabiopelosin I don’t particularly like them, but can we just use the default Ruby globals instead? I.e. $? in this situation?

@fabiopelosin
Copy link
Member

@alloy I was planning to go back to $? as long as we support Ruby 1.8.7 because it is just not worth it (working on another gem I have disabled this check on the cocoapods configuration of RuboCop exactly for this reason).

@alloy
Copy link
Member

alloy commented Aug 20, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants