[ruby-core:98230] [Ruby master Feature#16791] Shortcut for Process::Status.exitstatus
From:
eregontp@...
Date:
2020-05-09 12:03:39 UTC
List:
ruby-core #98230
Issue #16791 has been updated by Eregon (Benoit Daloze).
nobu (Nobuyoshi Nakada) wrote in #note-7:
> It may be acceptable to let `exit` accept a `SystemExit` instance though.
I think that would be useful.
I'd guess it would behave as something like:
```ruby
# useful if terminated by a signal:
exit(status) =>
exit(status.exitstatus || status.termsig || status.stopsig || 1)
# or maybe the simpler
exit(status) =>
exit(status.exitstatus || 1)
# but then no information if terminated by signal, which is bad
```
It's probably even better to raise a `SignalException` on `exit(status)` if `status.signaled?`, that way the information is completely forwarded to the parent process.
----------------------------------------
Feature #16791: Shortcut for Process::Status.exitstatus
https://bugs.ruby-lang.org/issues/16791#change-85470
* Author: 0x81000000 (/ /)
* Status: Open
* Priority: Normal
----------------------------------------
[Updated]
```
s = `csc x.cs`.sub(/.*?\n\n/m, '')
puts s if s != ''; exit $?.exitstatus if $?.exitstatus > 0
system 'mono x.exe'; exit $?.exitstatus
```
```
class Process::Status
alias :es :exitstatus
end
```
```
s = `csc x.cs`.sub(/.*?\n\n/m, '')
puts s if s != ''; exit $?.es if $?.es > 0
system 'mono x.exe'; exit $?.es
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>