octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #47807] run behaves differently from Matlab on


From: Julien Bect
Subject: [Octave-bug-tracker] [bug #47807] run behaves differently from Matlab on function m-files
Date: Mon, 16 May 2016 20:43:56 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #10, bug #47807 (project octave):

Here is a simple modification of the existing run.m that behaves properly on
the example of comment #8:


function run (script)

  if (nargin != 1)
    print_usage ();
  endif

  [d, f, ext] = fileparts (script);

  if (isempty (d))
    % Do not change directory if the input argument has no path
    evalin ("caller", f, "rethrow (lasterror ())");
  else
    if (exist (d, "dir"))
      startdir = pwd ();
      d = make_absolute_filename (d);
      unwind_protect
        cd (d);
        evalin ("caller", f, "rethrow (lasterror ())");
      unwind_protect_cleanup
        if (strcmp (d, pwd ()))
          cd (startdir);
        endif
      end_unwind_protect
    else
      error ("run: the path %s doesn't exist", d);
    endif
  endif
endfunction


What do you think?


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47807>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]