Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created January 4, 2011 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/765328 to your computer and use it in GitHub Desktop.
Save luislavena/765328 to your computer and use it in GitHub Desktop.
C:\Users\Luis>irb
irb(main):001:0> require 'rbconfig'
=> true
irb(main):002:0> NULL = RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ ? 'NUL' : '/dev/null'
=> "NUL"
irb(main):003:0> success = system("git --version >#{NULL} 2>&1")
=> true
irb(main):004:0> success
=> true
irb(main):005:0> $?
=> #<Process::Status: pid 1040 exit 0>
irb(main):006:0> $?.success?
=> true
irb(main):007:0> success = system("git-foo --version >#{NULL} 2>&1")
=> false
irb(main):008:0> success
=> false
irb(main):009:0> $?
=> #<Process::Status: pid 3588 exit 1>
irb(main):010:0> $?.success?
=> false
irb(main):011:0> RUBY_DESCRIPTION
=> "ruby 1.9.2p136 (2010-12-25) [i386-mingw32]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment