rdoc update.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-01-15 13:45:06 +00:00
parent 1084032fb4
commit c157583627

19
io.c
View File

@ -4790,13 +4790,15 @@ pop_last_hash(int *argc_p, VALUE *argv)
* The last argument <i>opt</i> qualifies <i>mode</i>. * The last argument <i>opt</i> qualifies <i>mode</i>.
* *
* # set IO encoding * # set IO encoding
* nkf_io = IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") * IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io|
* euc_jp_string = nkf_io.read * euc_jp_string = nkf_io.read
* }
* *
* # merge standard output and standard error using * # merge standard output and standard error using
* # spawn option. See the document of Kernel.spawn. * # spawn option. See the document of Kernel.spawn.
* ls_io = IO.popen(["ls", "/", :err=>[:child, :out]]) * IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io|
* ls_result_with_error = ls_io.read * ls_result_with_error = ls_io.read
* }
* *
* Raises exceptions which <code>IO.pipe</code> and * Raises exceptions which <code>IO.pipe</code> and
* <code>Kernel.spawn</code> raise. * <code>Kernel.spawn</code> raise.
@ -4818,9 +4820,10 @@ pop_last_hash(int *argc_p, VALUE *argv)
* *
* f = IO.popen("uname") * f = IO.popen("uname")
* p f.readlines * p f.readlines
* f.close
* puts "Parent is #{Process.pid}" * puts "Parent is #{Process.pid}"
* IO.popen("date") { |f| puts f.gets } * IO.popen("date") { |f| puts f.gets }
* IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f}"} * IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"}
* p $? * p $?
* IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f| * IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f|
* f.puts "bar"; f.close_write; puts f.gets * f.puts "bar"; f.close_write; puts f.gets
@ -4829,11 +4832,11 @@ pop_last_hash(int *argc_p, VALUE *argv)
* <em>produces:</em> * <em>produces:</em>
* *
* ["Linux\n"] * ["Linux\n"]
* Parent is 26166 * Parent is 21346
* Wed Apr 9 08:53:52 CDT 2003 * Thu Jan 15 22:41:19 JST 2009
* 26169 is here, f is * 21346 is here, f is #<IO:fd 3>
* 26166 is here, f is #<IO:0x401b3d44> * 21352 is here, f is nil
* #<Process::Status: pid=26166,exited(0)> * #<Process::Status: pid 21352 exit 0>
* <foo>bar;zot; * <foo>bar;zot;
*/ */