[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65599] [ruby-trunk - Bug #10362] spawn doesn't raise exception on redirection error

From: normalperson@...
Date: 2014-10-10 18:50:21 UTC
List: ruby-core #65599
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/

In This Thread

Prev Next