Mercurial > hg > octave-shane
changeset 11395:0754a4e271f4
run.m: use source to execute script
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 19 Dec 2010 22:42:57 -0500 |
parents | ecd87194adb6 |
children | 7b563cf94d8d |
files | scripts/ChangeLog scripts/miscellaneous/run.m |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-12-19 John W. Eaton <jwe@octave.org> + + * miscellaneous/run.m: Use source to execute script. + 2010-12-18 Ben Abbott <bpabbott@mac.com> * plot/view.m: Return azimuth and elevation for nargin == 0.
--- a/scripts/miscellaneous/run.m +++ b/scripts/miscellaneous/run.m @@ -38,10 +38,11 @@ wd = pwd (); unwind_protect cd (d); - if (! exist (f, "file") || ! strcmp (ext, ".m")) + if (! exist (cstrcat (f, ext), "file")) error ("run: file must exist and be a valid Octave script file"); endif - evalin ("caller", [f, ";"], "rethrow (lasterror ())"); + evalin ("caller", sprintf ("source (\"%s%s\");", f, ext), + "rethrow (lasterror ())"); unwind_protect_cleanup cd (wd); end_unwind_protect @@ -49,8 +50,9 @@ error ("run: the path %s doesn't exist", d); endif else - if (exist (f, "file")) - evalin ("caller", [f, ";"], "rethrow (lasterror ())"); + if (exist (s, "file")) + evalin ("caller", sprintf ("source (\"%s\");", s), + "rethrow (lasterror ())"); else error ("run: %s not found", s); endif