We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
$ ruby --version ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18] $ pry --version Pry version 0.13.1 on Ruby 2.7.1
In a file called system_call_exit_status.rb, I have the following:
system_call_exit_status.rb
system "exit 1" puts "-- $? => #{$?}" puts "-- $?.success? => #{$?.success?}"
which outputs
$ ruby system_call_exit_status.rb -- $? => pid 94141 exit 1 -- $?.success? => false
The example above seem to demonstrate that system writes the exit status to $?, as described in documentation
system
$?
Similar output can be seen by invoking pry on the file, i.e.
pry
$ pry system_call_exit_status.rb -- $? => pid 94141 exit 1 -- $?.success? => false
I would expect pry REPL to behave the same.
Unfortunately, the actual output from pry REPL seem to be different:
[1] pry(main)> system "exit 1" => false [2] pry(main)> puts "-- $? => #{$?}" -- $? => pid 94155 exit 0 => nil [3] pry(main)> puts "-- $?.success? => #{$?.success?}" -- $?.success? => true => nil
Is this expected? I'm guessing pry REPL session overrides $? on calls to system, because using backticks seem to show accurate behavior, i.e.
[1] pry(main)> `exit 1` => "" [2] pry(main)> puts "-- $? => #{$?}" -- $? => pid 94156 exit 1 => nil [3] pry(main)> puts "-- $?.success? => #{$?.success?}" -- $?.success? => false => nil
The text was updated successfully, but these errors were encountered:
pry#2141 fix system exit status
e628f96
91d06e9
Successfully merging a pull request may close this issue.
Setup
Expected
In a file called
system_call_exit_status.rb
, I have the following:which outputs
The example above seem to demonstrate that
system
writes the exit status to$?
, as described in documentationSimilar output can be seen by invoking
pry
on the file, i.e.I would expect
pry
REPL to behave the same.Actual
Unfortunately, the actual output from
pry
REPL seem to be different:Is this expected? I'm guessing
pry
REPL session overrides$?
on calls tosystem
, because using backticks seem to show accurate behavior, i.e.The text was updated successfully, but these errors were encountered: