# HG changeset patch # User John W. Eaton # Date 1292816577 18000 # Node ID 0754a4e271f407c030bd5f86d4a58fe893b739dc # Parent ecd87194adb6c189ae158e7a54b5bfc85a472362 run.m: use source to execute script diff -r ecd87194adb6 -r 0754a4e271f4 scripts/ChangeLog --- a/scripts/ChangeLog Sun Dec 19 10:25:58 2010 +0100 +++ b/scripts/ChangeLog Sun Dec 19 22:42:57 2010 -0500 @@ -1,3 +1,7 @@ +2010-12-19 John W. Eaton + + * miscellaneous/run.m: Use source to execute script. + 2010-12-18 Ben Abbott * plot/view.m: Return azimuth and elevation for nargin == 0. diff -r ecd87194adb6 -r 0754a4e271f4 scripts/miscellaneous/run.m --- a/scripts/miscellaneous/run.m Sun Dec 19 10:25:58 2010 +0100 +++ b/scripts/miscellaneous/run.m Sun Dec 19 22:42:57 2010 -0500 @@ -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