Mercurial > octave-nkf
changeset 18445:1363d909c577
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.
author | Felipe G. Nievinski <fgnievinski@gmail.com> |
---|---|
date | Tue, 11 Feb 2014 00:42:43 -0200 |
parents | b0aba84cf80f |
children | 634d9989bf7b |
files | scripts/miscellaneous/run.m |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);