summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-io/mrblib/kernel.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-12-07 18:11:06 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-12-07 18:11:06 +0900
commitd75266dd1bade53255044460a9cd74596addaa84 (patch)
treeac97feb393da5597855dd8f79a7b8feba17c5c14 /mrbgems/mruby-io/mrblib/kernel.rb
parent10ed730e4bd921cf4d8fe6f6d2e3cb3f0840f3b7 (diff)
parent3c8e1f94c44252c836f79a48bb17726da28e2756 (diff)
downloadmruby-d75266dd1bade53255044460a9cd74596addaa84.tar.gz
mruby-d75266dd1bade53255044460a9cd74596addaa84.zip
Add 'mrbgems/mruby-io/' from commit '3c8e1f94c44252c836f79a48bb17726da28e2756'
git-subtree-dir: mrbgems/mruby-io git-subtree-mainline: 10ed730e4bd921cf4d8fe6f6d2e3cb3f0840f3b7 git-subtree-split: 3c8e1f94c44252c836f79a48bb17726da28e2756
Diffstat (limited to 'mrbgems/mruby-io/mrblib/kernel.rb')
-rw-r--r--mrbgems/mruby-io/mrblib/kernel.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/mrbgems/mruby-io/mrblib/kernel.rb b/mrbgems/mruby-io/mrblib/kernel.rb
new file mode 100644
index 000000000..373b76f98
--- /dev/null
+++ b/mrbgems/mruby-io/mrblib/kernel.rb
@@ -0,0 +1,15 @@
+module Kernel
+ def `(cmd)
+ IO.popen(cmd) { |io| io.read }
+ end
+
+ def open(file, *rest, &block)
+ raise ArgumentError unless file.is_a?(String)
+
+ if file[0] == "|"
+ IO.popen(file[1..-1], *rest, &block)
+ else
+ File.open(file, *rest, &block)
+ end
+ end
+end