* [ruby-core:65595] [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
@ 2014-10-10 10:04 ` bdimych
2014-10-10 18:47 ` [ruby-core:65598] " Eric Wong
2014-10-10 18:50 ` [ruby-core:65599] [ruby-trunk - Bug #10362] " normalperson
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: bdimych @ 2014-10-10 10:04 UTC (permalink / raw
To: ruby-core
Issue #10362 has been reported by Dmitry Bolshakov.
----------------------------------------
Bug #10362: spawn doesn't raise exception on redirection error
https://bugs.ruby-lang.org/issues/10362
* Author: Dmitry Bolshakov
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~
irb(main):002:0*
irb(main):003:0*
irb(main):004:0* system 'cmd', '/c', 'echo', 'aaa'
aaa
=> true
irb(main):005:0>
irb(main):006:0*
irb(main):007:0*
irb(main):008:0* system 'cmd', '/c', 'echo', 'aaa', :out => ['bad/file.txt', 'w']
=> nil
irb(main):009:0>
irb(main):010:0*
irb(main):011:0*
irb(main):012:0*
irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
Errno::ENOENT: No such file or directory - bad/file.txt
from (irb):13:in `initialize'
from (irb):13:in `open'
from (irb):13
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):014:0>
irb(main):015:0*
irb(main):016:0*
~~~
exception is much more descriptive than just nil
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:65598] Re: [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error
2014-10-10 10:04 ` [ruby-core:65595] [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error bdimych
@ 2014-10-10 18:47 ` Eric Wong
0 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2014-10-10 18:47 UTC (permalink / raw
To: Ruby developers
bdimych@narod.ru wrote:
> irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
> Errno::ENOENT: No such file or directory - bad/file.txt
> from (irb):13:in `initialize'
> from (irb):13:in `open'
> from (irb):13
> from C:/Ruby200/bin/irb:12:in `<main>'
>
> exception is much more descriptive than just nil
Right, but I think the `system' method is intended to hide errors by default.
$? must be checked when `system' returns nil:
if system('non-existent-command').nil?
$? => #<Process::Status: pid ... exit 127>
end
I think it is in the spec for `system' to behave like this.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:65599] [ruby-trunk - Bug #10362] spawn doesn't raise exception on redirection error
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
2014-10-10 10:04 ` [ruby-core:65595] [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error bdimych
@ 2014-10-10 18:50 ` normalperson
2014-10-11 5:02 ` [ruby-core:65611] " nobu
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: normalperson @ 2014-10-10 18:50 UTC (permalink / raw
To: ruby-core
Issue #10362 has been updated by Eric Wong.
bdimych@narod.ru wrote:
> irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
> Errno::ENOENT: No such file or directory - bad/file.txt
> from (irb):13:in `initialize'
> from (irb):13:in `open'
> from (irb):13
> from C:/Ruby200/bin/irb:12:in `<main>'
>
> exception is much more descriptive than just nil
Right, but I think the `system' method is intended to hide errors by default.
$? must be checked when `system' returns nil:
if system('non-existent-command').nil?
$? => #<Process::Status: pid ... exit 127>
end
I think it is in the spec for `system' to behave like this.
----------------------------------------
Bug #10362: spawn doesn't raise exception on redirection error
https://bugs.ruby-lang.org/issues/10362#change-49340
* Author: Dmitry Bolshakov
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~
irb(main):002:0*
irb(main):003:0*
irb(main):004:0* system 'cmd', '/c', 'echo', 'aaa'
aaa
=> true
irb(main):005:0>
irb(main):006:0*
irb(main):007:0*
irb(main):008:0* system 'cmd', '/c', 'echo', 'aaa', :out => ['bad/file.txt', 'w']
=> nil
irb(main):009:0>
irb(main):010:0*
irb(main):011:0*
irb(main):012:0*
irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
Errno::ENOENT: No such file or directory - bad/file.txt
from (irb):13:in `initialize'
from (irb):13:in `open'
from (irb):13
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):014:0>
irb(main):015:0*
irb(main):016:0*
~~~
exception is much more descriptive than just nil
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:65611] [ruby-trunk - Bug #10362] spawn doesn't raise exception on redirection error
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
2014-10-10 10:04 ` [ruby-core:65595] [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error bdimych
2014-10-10 18:50 ` [ruby-core:65599] [ruby-trunk - Bug #10362] " normalperson
@ 2014-10-11 5:02 ` nobu
2014-10-11 5:42 ` [ruby-core:65612] " Eric Wong
2014-10-11 5:50 ` [ruby-core:65613] " normalperson
2019-07-09 4:37 ` [ruby-core:93626] [Ruby master Bug#10362] " merch-redmine
4 siblings, 1 reply; 7+ messages in thread
From: nobu @ 2014-10-11 5:02 UTC (permalink / raw
To: ruby-core
Issue #10362 has been updated by Nobuyoshi Nakada.
Yes, it's intentional spec, but to raise errors `Process.spawn` and `Process.wait` are needed.
It may be good to add an option for errors to `system`.
----------------------------------------
Bug #10362: spawn doesn't raise exception on redirection error
https://bugs.ruby-lang.org/issues/10362#change-49350
* Author: Dmitry Bolshakov
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~
irb(main):002:0*
irb(main):003:0*
irb(main):004:0* system 'cmd', '/c', 'echo', 'aaa'
aaa
=> true
irb(main):005:0>
irb(main):006:0*
irb(main):007:0*
irb(main):008:0* system 'cmd', '/c', 'echo', 'aaa', :out => ['bad/file.txt', 'w']
=> nil
irb(main):009:0>
irb(main):010:0*
irb(main):011:0*
irb(main):012:0*
irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
Errno::ENOENT: No such file or directory - bad/file.txt
from (irb):13:in `initialize'
from (irb):13:in `open'
from (irb):13
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):014:0>
irb(main):015:0*
irb(main):016:0*
~~~
exception is much more descriptive than just nil
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:65612] Re: [ruby-trunk - Bug #10362] spawn doesn't raise exception on redirection error
2014-10-11 5:02 ` [ruby-core:65611] " nobu
@ 2014-10-11 5:42 ` Eric Wong
0 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2014-10-11 5:42 UTC (permalink / raw
To: Ruby developers
On the other hand, maybe we should allow Ruby-level options to `system'
to raise, but continue hiding errors when running the command itself.
In other words:
# continue old 1.8 behavior if redirect is done via shell
# (n.b. this example is bad practice, but just an example)
system('true >bad/file.txt') -> nil
So I think the original example by Dmitry should raise:
system('true', out: %w(bad/file.txt w)) -> Errno...
Maybe this (potentially incompatible) change can be acceptable
for 2.2 (if not, then for Ruby 3.0)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:65613] [ruby-trunk - Bug #10362] spawn doesn't raise exception on redirection error
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
` (2 preceding siblings ...)
2014-10-11 5:02 ` [ruby-core:65611] " nobu
@ 2014-10-11 5:50 ` normalperson
2019-07-09 4:37 ` [ruby-core:93626] [Ruby master Bug#10362] " merch-redmine
4 siblings, 0 replies; 7+ messages in thread
From: normalperson @ 2014-10-11 5:50 UTC (permalink / raw
To: ruby-core
Issue #10362 has been updated by Eric Wong.
On the other hand, maybe we should allow Ruby-level options to `system'
to raise, but continue hiding errors when running the command itself.
In other words:
# continue old 1.8 behavior if redirect is done via shell
# (n.b. this example is bad practice, but just an example)
system('true >bad/file.txt') -> nil
So I think the original example by Dmitry should raise:
system('true', out: %w(bad/file.txt w)) -> Errno...
Maybe this (potentially incompatible) change can be acceptable
for 2.2 (if not, then for Ruby 3.0)
----------------------------------------
Bug #10362: spawn doesn't raise exception on redirection error
https://bugs.ruby-lang.org/issues/10362#change-49351
* Author: Dmitry Bolshakov
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~
irb(main):002:0*
irb(main):003:0*
irb(main):004:0* system 'cmd', '/c', 'echo', 'aaa'
aaa
=> true
irb(main):005:0>
irb(main):006:0*
irb(main):007:0*
irb(main):008:0* system 'cmd', '/c', 'echo', 'aaa', :out => ['bad/file.txt', 'w']
=> nil
irb(main):009:0>
irb(main):010:0*
irb(main):011:0*
irb(main):012:0*
irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
Errno::ENOENT: No such file or directory - bad/file.txt
from (irb):13:in `initialize'
from (irb):13:in `open'
from (irb):13
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):014:0>
irb(main):015:0*
irb(main):016:0*
~~~
exception is much more descriptive than just nil
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:93626] [Ruby master Bug#10362] spawn doesn't raise exception on redirection error
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
` (3 preceding siblings ...)
2014-10-11 5:50 ` [ruby-core:65613] " normalperson
@ 2019-07-09 4:37 ` merch-redmine
4 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2019-07-09 4:37 UTC (permalink / raw
To: ruby-core
Issue #10362 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
`system` was made more strict for redirection errors between Ruby 2.2 and 2.3:
```
speedstar$ ruby22 -e "p system('true', out: %w(bad/file.txt w))"
nil
speedstar$ ruby23 -e "p system('true', out: %w(bad/file.txt w))"
-e:1:in `system': No such file or directory - bad/file.txt (Errno::ENOENT)
from -e:1:in `<main>'
```
----------------------------------------
Bug #10362: spawn doesn't raise exception on redirection error
https://bugs.ruby-lang.org/issues/10362#change-79233
* Author: bdimych (Dmitry Bolshakov)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~
irb(main):002:0*
irb(main):003:0*
irb(main):004:0* system 'cmd', '/c', 'echo', 'aaa'
aaa
=> true
irb(main):005:0>
irb(main):006:0*
irb(main):007:0*
irb(main):008:0* system 'cmd', '/c', 'echo', 'aaa', :out => ['bad/file.txt', 'w']
=> nil
irb(main):009:0>
irb(main):010:0*
irb(main):011:0*
irb(main):012:0*
irb(main):013:0* system 'cmd', '/c', 'echo', 'aaa', :out => File.open('bad/file.txt', 'w')
Errno::ENOENT: No such file or directory - bad/file.txt
from (irb):13:in `initialize'
from (irb):13:in `open'
from (irb):13
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):014:0>
irb(main):015:0*
irb(main):016:0*
~~~
exception is much more descriptive than just nil
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-07-09 4:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-10362.20141010100402@ruby-lang.org>
2014-10-10 10:04 ` [ruby-core:65595] [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error bdimych
2014-10-10 18:47 ` [ruby-core:65598] " Eric Wong
2014-10-10 18:50 ` [ruby-core:65599] [ruby-trunk - Bug #10362] " normalperson
2014-10-11 5:02 ` [ruby-core:65611] " nobu
2014-10-11 5:42 ` [ruby-core:65612] " Eric Wong
2014-10-11 5:50 ` [ruby-core:65613] " normalperson
2019-07-09 4:37 ` [ruby-core:93626] [Ruby master Bug#10362] " merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).