* io.c (rb_io_popen): update the document for the first argument and
exceptions. * process.c (rb_f_exec, rb_f_system): update the document for exceptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c7558580f6
commit
63dedc7de4
26
io.c
26
io.c
@ -2798,23 +2798,27 @@ rb_io_popen(str, argc, argv, klass)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* IO.popen(cmd_string, mode="r" ) => io
|
* IO.popen(cmd, mode="r") => io
|
||||||
* IO.popen(cmd_string, mode="r" ) {|io| block } => obj
|
* IO.popen(cmd, mode="r") {|io| block } => obj
|
||||||
*
|
*
|
||||||
* Runs the specified command string as a subprocess; the subprocess's
|
* Runs the specified command as a subprocess; the subprocess's
|
||||||
* standard input and output will be connected to the returned
|
* standard input and output will be connected to the returned
|
||||||
* <code>IO</code> object. If <i>cmd_string</i> starts with a
|
* <code>IO</code> object. If _cmd_ is a +String+
|
||||||
* ``<code>-</code>'', then a new instance of Ruby is started as the
|
* ``<code>-</code>'', then a new instance of Ruby is started as the
|
||||||
* subprocess. The default mode for the new file object is ``r'', but
|
* subprocess. If <i>cmd</i> is an +Array+ of +String+, then it will
|
||||||
* <i>mode</i> may be set to any of the modes listed in the description
|
* be used as the subprocess's +argv+ bypassing a shell. The default
|
||||||
* for class IO.
|
* mode for the new file object is ``r'', but <i>mode</i> may be set
|
||||||
|
* to any of the modes listed in the description for class IO.
|
||||||
|
*
|
||||||
|
* Raises exceptions which <code>IO::pipe</code> and
|
||||||
|
* <code>Kernel::system</code> raise.
|
||||||
*
|
*
|
||||||
* If a block is given, Ruby will run the command as a child connected
|
* If a block is given, Ruby will run the command as a child connected
|
||||||
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
|
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
|
||||||
* parameter to the block. In this case <code>IO::popen</code> returns
|
* parameter to the block. In this case <code>IO::popen</code> returns
|
||||||
* the value of the block.
|
* the value of the block.
|
||||||
*
|
*
|
||||||
* If a block is given with a <i>cmd_string</i> of ``<code>-</code>'',
|
* If a block is given with a _cmd_ of ``<code>-</code>'',
|
||||||
* the block will be run in two separate processes: once in the parent,
|
* the block will be run in two separate processes: once in the parent,
|
||||||
* and once in a child. The parent process will be passed the pipe
|
* and once in a child. The parent process will be passed the pipe
|
||||||
* object as a parameter to the block, the child version of the block
|
* object as a parameter to the block, the child version of the block
|
||||||
@ -2825,8 +2829,11 @@ rb_io_popen(str, argc, argv, klass)
|
|||||||
* f = IO.popen("uname")
|
* f = IO.popen("uname")
|
||||||
* p f.readlines
|
* p f.readlines
|
||||||
* 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}"}
|
||||||
|
* IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f|
|
||||||
|
* f.puts "bar"; f.close_write; puts f.gets
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
@ -2835,6 +2842,7 @@ rb_io_popen(str, argc, argv, klass)
|
|||||||
* Wed Apr 9 08:53:52 CDT 2003
|
* Wed Apr 9 08:53:52 CDT 2003
|
||||||
* 26169 is here, f is
|
* 26169 is here, f is
|
||||||
* 26166 is here, f is #<IO:0x401b3d44>
|
* 26166 is here, f is #<IO:0x401b3d44>
|
||||||
|
* <foo>bar;zot;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
12
process.c
12
process.c
@ -1225,6 +1225,9 @@ rb_check_argv(argc, argv)
|
|||||||
* used, so the running command may inherit some of the environment of
|
* used, so the running command may inherit some of the environment of
|
||||||
* the original program (including open file descriptors).
|
* the original program (including open file descriptors).
|
||||||
*
|
*
|
||||||
|
* Raises SystemCallError if the _command_ couldn't execute (typically
|
||||||
|
* <code>Errno::ENOENT</code> when it was not found).
|
||||||
|
*
|
||||||
* exec "echo *" # echoes list of files in current directory
|
* exec "echo *" # echoes list of files in current directory
|
||||||
* # never get here
|
* # never get here
|
||||||
*
|
*
|
||||||
@ -1573,11 +1576,10 @@ rb_spawn(argc, argv)
|
|||||||
* call-seq:
|
* call-seq:
|
||||||
* system(cmd [, arg, ...]) => true or false
|
* system(cmd [, arg, ...]) => true or false
|
||||||
*
|
*
|
||||||
* Executes _cmd_ in a subshell, returning +true+ if
|
* Executes _cmd_ in a subshell, returning +true+ if the command ran
|
||||||
* the command was found and ran successfully, +false+
|
* successfully, +false+ otherwise. An error status is available in
|
||||||
* otherwise. An error status is available in <code>$?</code>. The
|
* <code>$?</code>. The arguments are processed in the same way as
|
||||||
* arguments are processed in the same way as for
|
* for <code>Kernel::exec</code>, and raises same exceptions as it.
|
||||||
* <code>Kernel::exec</code>.
|
|
||||||
*
|
*
|
||||||
* system("echo *")
|
* system("echo *")
|
||||||
* system("echo", "*")
|
* system("echo", "*")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user