Mercurial > hg > octave-lyh
comparison scripts/miscellaneous/perl.m @ 14818:c6ae30f73946
Look for perl/python scripts in Octave load path (bug #36729)
* perl.m, python.m: Look for scripts using file_in_loadpath.
Update docstring for new behavior.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 29 Jun 2012 08:45:54 -0700 |
parents | 72c96de7a403 |
children | 333243133364 |
comparison
equal
deleted
inserted
replaced
14817:67897baaa05f | 14818:c6ae30f73946 |
---|---|
15 ## You should have received a copy of the GNU General Public License | 15 ## You should have received a copy of the GNU General Public License |
16 ## along with Octave; see the file COPYING. If not, see | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | 17 ## <http://www.gnu.org/licenses/>. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {[@var{output}, @var{status}] =} perl (@var{scriptfile}) | 20 ## @deftypefn {Function File} {@var{output} =} perl (@var{scriptfile}) |
21 ## @deftypefnx {Function File} {[@var{output}, @var{status}] =} perl (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{}) | 21 ## @deftypefnx {Function File} {@var{output} =} perl (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{}) |
22 ## Invoke Perl script @var{scriptfile} with possibly a list of | 22 ## @deftypefnx {Function File} {[@var{output}, @var{status}] =} perl (@dots{}) |
23 ## command line arguments. | 23 ## Invoke Perl script @var{scriptfile}, possibly with a list of command line |
24 ## Returns output in @var{output} and status | 24 ## arguments. Return output in @var{output} and optional status in |
25 ## in @var{status}. | 25 ## @var{status}. If @var{scriptfile} is not an absolute file name it is |
26 ## @seealso{system} | 26 ## is searched for in the current directory and then in the Octave loadpath. |
27 ## @seealso{system, python} | |
27 ## @end deftypefn | 28 ## @end deftypefn |
28 | 29 |
29 function [output, status] = perl (scriptfile = "-e ''", varargin) | 30 function [output, status] = perl (scriptfile = "-e ''", varargin) |
30 | 31 |
31 ## VARARGIN is intialized to {}(1x0) if no additional arguments are | 32 ## VARARGIN is intialized to {}(1x0) if no additional arguments are |
32 ## supplied, so there is no need to check for it, or provide an | 33 ## supplied, so there is no need to check for it, or provide an |
33 ## initial value in the argument list of the function definition. | 34 ## initial value in the argument list of the function definition. |
34 | 35 |
35 if (ischar (scriptfile) | 36 if (ischar (scriptfile) |
36 && ((nargin != 1 && iscellstr (varargin)) | 37 && ( (nargin == 1 && ! isempty (scriptfile)) |
37 || (nargin == 1 && ! isempty (scriptfile)))) | 38 || (nargin != 1 && iscellstr (varargin)))) |
39 if (! strcmp (scriptfile(1:2), "-e")) | |
40 ## Attempt to find file in loadpath. No effect for absolute filenames. | |
41 scriptfile = file_in_loadpath (scriptfile); | |
42 endif | |
43 | |
38 [status, output] = system (cstrcat ("perl ", scriptfile, | 44 [status, output] = system (cstrcat ("perl ", scriptfile, |
39 sprintf (" %s", varargin{:}))); | 45 sprintf (" %s", varargin{:}))); |
40 else | 46 else |
41 error ("perl: invalid arguments"); | 47 error ("perl: invalid arguments"); |
42 endif | 48 endif |