[#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:65598] Re: [ruby-trunk - Bug #10362] [Open] spawn doesn't raise exception on redirection error

From: Eric Wong <normalperson@...>
Date: 2014-10-10 18:47:28 UTC
List: ruby-core #65598
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.

In This Thread

Prev Next