Mercurial > octave
comparison libinterp/corefcn/toplev.cc @ 28604:69cba42a01ca stable
doc: Re-order system() docs to match order of parameters.
* toplev.cc (Fsystem): Move discussion of third input parameter to occur after
discussion of second input parameter. Wrap lines to 80 characters.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 29 Jul 2020 13:14:40 -0700 |
parents | bd51beb6205e |
children | 26cfccfee9a0 0a5b15007766 |
comparison
equal
deleted
inserted
replaced
28602:79558e694c6c | 28604:69cba42a01ca |
---|---|
182 @deftypefnx {} {} system ("@var{string}", @var{return_output}) | 182 @deftypefnx {} {} system ("@var{string}", @var{return_output}) |
183 @deftypefnx {} {} system ("@var{string}", @var{return_output}, @var{type}) | 183 @deftypefnx {} {} system ("@var{string}", @var{return_output}, @var{type}) |
184 @deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{}) | 184 @deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{}) |
185 Execute a shell command specified by @var{string}. | 185 Execute a shell command specified by @var{string}. |
186 | 186 |
187 If the optional argument @var{type} is @qcode{"async"}, the process is | 187 If @var{system} is called with one or more output arguments, or if the optional |
188 started in the background and the process ID of the child process is | 188 argument @var{return_output} is true and the subprocess is started |
189 returned immediately. Otherwise, the child process is started and Octave | |
190 waits until it exits. If the @var{type} argument is omitted, it defaults to | |
191 the value @qcode{"sync"}. | |
192 | |
193 If @var{system} is called with one or more output arguments, or if the | |
194 optional argument @var{return_output} is true and the subprocess is started | |
195 synchronously, then the output from the command is returned as a variable. | 189 synchronously, then the output from the command is returned as a variable. |
196 Otherwise, if the subprocess is executed synchronously, its output is sent | 190 Otherwise, if the subprocess is executed synchronously, its output is sent to |
197 to the standard output. To send the output of a command executed with | 191 the standard output. To send the output of a command executed with |
198 @code{system} through the pager, use a command like | 192 @code{system} through the pager, use a command like |
199 | 193 |
200 @example | 194 @example |
201 @group | 195 @group |
202 [~, text] = system ("cmd"); | 196 [~, text] = system ("cmd"); |
213 more on; | 207 more on; |
214 printf ("%s\n", nthargout (2, "system", "cmd")); | 208 printf ("%s\n", nthargout (2, "system", "cmd")); |
215 @end group | 209 @end group |
216 @end example | 210 @end example |
217 | 211 |
218 The @code{system} function can return two values. The first is the | 212 If the optional argument @var{type} is @qcode{"async"}, the process is started |
219 exit status of the command and the second is any output from the | 213 in the background and the process ID of the child process is returned |
220 command that was written to the standard output stream. For example, | 214 immediately. Otherwise, the child process is started and Octave waits until it |
215 exits. If the @var{type} argument is omitted, it defaults to the value | |
216 @qcode{"sync"}. | |
217 | |
218 The @code{system} function can return two values. The first is the exit status | |
219 of the command and the second is any output from the command that was written | |
220 to the standard output stream. For example, | |
221 | 221 |
222 @example | 222 @example |
223 [status, output] = system ("echo foo & exit 2"); | 223 [status, output] = system ("echo foo & exit 2"); |
224 @end example | 224 @end example |
225 | 225 |
226 @noindent | 226 @noindent |
227 will set the variable @var{output} to the string @samp{foo}, and the | 227 will set the variable @var{output} to the string @samp{foo}, and the variable |
228 variable @var{status} to the integer @samp{2}. | 228 @var{status} to the integer @samp{2}. |
229 | 229 |
230 For commands run asynchronously, @var{status} is the process id of the | 230 For commands run asynchronously, @var{status} is the process id of the command |
231 command shell that is started to run the command. | 231 shell that is started to run the command. |
232 | 232 |
233 The shell used for executing commands varies with operating system and is | 233 The shell used for executing commands varies with operating system and is |
234 typically @file{/bin/sh} for UNIX systems and @nospell{@file{cmd.exe}} for | 234 typically @file{/bin/sh} for UNIX systems and @nospell{@file{cmd.exe}} for |
235 Windows | 235 Windows systems. |
236 systems. | |
237 @seealso{unix, dos} | 236 @seealso{unix, dos} |
238 @end deftypefn */) | 237 @end deftypefn */) |
239 { | 238 { |
240 int nargin = args.length (); | 239 int nargin = args.length (); |
241 | 240 |