Project

General

Profile

Feature #14245 ยป 0001-io.c.patch

shugo (Shugo Maeda), 03/17/2018 11:47 AM

View differences:

NEWS
=== Compatibility issues (excluding feature bug fixes)
* File
* File.read, File.binread, File.write, File.binwrite, File.foreach,
and File.readlines do not invoke external commands even if the path
starts with the pipe character |. [Feature #14245]
=== Stdlib compatibility issues (excluding feature bug fixes)
=== C API updates
io.c
const convconfig_t *convconfig, mode_t perm)
{
VALUE cmd;
const int warn = klass == rb_cFile;
if ((warn || klass == rb_cIO) && !NIL_P(cmd = check_pipe_command(filename))) {
if (warn) {
rb_warn("IO.%"PRIsVALUE" called on File to invoke external command",
rb_id2str(rb_frame_this_func()));
}
if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
}
else {
test/ruby/test_io.rb
def test_read_command
assert_equal("foo\n", IO.read("|echo foo"))
assert_warn(/invoke external command/) do
assert_raise(Errno::ENOENT, Errno::EINVAL) do
File.read("|#{EnvUtil.rubybin} -e puts")
end
assert_warn(/invoke external command/) do
assert_raise(Errno::ENOENT, Errno::EINVAL) do
File.binread("|#{EnvUtil.rubybin} -e puts")
end
assert_raise(Errno::ENOENT, Errno::EINVAL) do
    (1-1/1)