Mercurial > hg > octave-nkf
annotate scripts/deprecated/shell_cmd.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | 5d5685216876 |
children | bc924baa2c4e |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14018
diff
changeset
|
1 ## Copyright (C) 2012 Rik Wehbring |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
2 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
4 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
9 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
14 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
18 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
19 ## "-*- texinfo -*- |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
20 ## @deftypefn {Built-in Function} {} shell_cmd (@var{string}) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
21 ## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output}) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
22 ## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output}, @var{type}) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
23 ## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@dots{}) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
24 ## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@var{string}, @var{return_output}, @var{type}) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
25 ## Execute a shell command specified by @var{string}. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
26 ## If the optional argument @var{type} is "async", the process |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
27 ## is started in the background and the process id of the child process |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
28 ## is returned immediately. Otherwise, the process is started and |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
29 ## Octave waits until it exits. If the @var{type} argument is omitted, it |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
30 ## defaults to a value of "sync". |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
31 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
32 ## If the optional argument @var{return_output} is true and the subprocess |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
33 ## is started synchronously, or if @var{shell_cmd} is called with one input |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
34 ## argument and one or more output arguments, then the output from the command |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
35 ## is returned. Otherwise, if the subprocess is executed synchronously, its |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
36 ## output is sent to the standard output. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
37 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
38 ## The @code{shell_cmd} function can return two values. The first is the |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
39 ## exit status of the command and the second is any output from the |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
40 ## command that was written to the standard output stream. For example, |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
41 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
42 ## @example |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
43 ## [status, output] = shell_cmd ("echo foo; exit 2"); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
44 ## @end example |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
45 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
46 ## @noindent |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
47 ## will set the variable @code{output} to the string @samp{foo}, and the |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
48 ## variable @code{status} to the integer @samp{2}. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
49 ## |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
50 ## For commands run asynchronously, @var{status} is the process id of the |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
51 ## command shell that is started to run the command. |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
52 ## @seealso{system, unix, dos} |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
53 ## @end deftypefn |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
54 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
55 ## Deprecated in version 3.6 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
56 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
57 function [status, output] = shell_cmd (varargin) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
58 persistent warned = false; |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
59 if (! warned) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
60 warned = true; |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
61 warning ("Octave:deprecated-function", |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
62 "shell_cmd is obsolete and will be removed from a future version of Octave; please use system instead"); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
63 endif |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
64 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
65 [status, output] = system (varargin{:}); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
66 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
67 endfunction |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
68 |