add cmd (command output expression).

This commit is contained in:
Tomoyuki Sahara
2013-08-23 16:00:08 +09:00
parent 5e8021bedb
commit 9dc875f246
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -1,4 +1,8 @@
module Kernel
def self.`(cmd)
IO.popen(cmd) { |io| io.read }
end
def open(file, *rest, &block)
raise ArgumentError unless file.is_a?(String)
+4
View File
@@ -232,6 +232,10 @@ assert('IO#fileno') do
io.closed?
end
assert('`cmd`') do
assert_equal `echo foo`, "foo\n"
end
assert('IO TEST CLEANUP') do
assert_nil MRubyIOTestUtil.io_test_cleanup
end