Created
September 12, 2013 20:24
-
-
Save jhoblitt/6543236 to your computer and use it in GitHub Desktop.
Testing `$?` with `open3#popen3`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open3' | |
cmd = 'ls not-a-real-path' | |
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| | |
end | |
p $? | |
exit_status = nil | |
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| | |
exit_status = wait_thr.value | |
end | |
p exit_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rvm use 1.9.3 | |
Using /home/jhoblitt/.rvm/gems/ruby-1.9.3-p448 | |
$ ruby --version | |
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux] | |
$ ruby exitstatus_test.rb | |
nil | |
#<Process::Status: pid 1163 exit 2> | |
$ rvm use 2.0.0 | |
Using /home/jhoblitt/.rvm/gems/ruby-2.0.0-p247 | |
$ ruby --version | |
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] | |
$ ruby exitstatus_test.rb | |
nil | |
#<Process::Status: pid 1313 exit 2> |
carlossg
commented
Sep 13, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment