# HG changeset patch # User Felipe G. Nievinski # Date 1392086563 7200 # Node ID 1363d909c5770799775dc33cb71507c09022dd7e # Parent b0aba84cf80fb3958d696ee8e685059aeaf3c32c run.m: Don't undo changes to current dir done by script that was run (bug #41543). * run.m: After running script, check that current directory was the same one where script was located. If it is, cd back to original directory, otherwise leave user in the directory that the script changed to. diff -r b0aba84cf80f -r 1363d909c577 scripts/miscellaneous/run.m --- a/scripts/miscellaneous/run.m Sat Feb 08 19:17:25 2014 -0500 +++ b/scripts/miscellaneous/run.m Tue Feb 11 00:42:43 2014 -0200 @@ -31,9 +31,10 @@ ## falling back to the script name without an extension. ## ## Implementation Note: If @var{script} includes a path component, then -## @code{run} first changes the directory to the directory where @var{script} -## is found. @code{run} then executes the script, and returns to the original -## directory. +## @code{run} first changes the working directory to the directory where +## @var{script} is found. Next, the script is executed. Finally, @code{run} +## returns to the original working directory unless @code{script} has +## specifically changed directories. ## @seealso{path, addpath, source} ## @end deftypefn @@ -65,7 +66,9 @@ evalin ("caller", sprintf ('source ("%s%s");', f, ext), "rethrow (lasterror ())"); unwind_protect_cleanup - cd (wd); + if (strcmp (d, pwd ())) + cd (wd); + endif end_unwind_protect else error ("run: the path %s doesn't exist", d);