bugGNU Octave - Bugs: bug #39889, run('path/to/file') doesn't when...


bug #39889: run('path/to/file') doesn't when ".m" is missing

Submitted by:  Jan Rüegg <rggjan>
Submitted on:  Thu Aug 29 08:55:30 2013  
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Mon Oct 21 16:05:41 2013, comment #11:

I committed your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/9ccb48d39ce9). I also re-wrote the docstring to make it clearer and added some input validation tests. This will be part of the next Octave release due out in a few weeks. Thanks for helping make Octave better.

Rik <rik5>
Project Administrator
Sun Oct 20 20:48:11 2013, comment #10:

Attached is a new patch. I tested its behavior with testrun.m (also attached).

I extended "run" to be able to run a script which is in the path (here scripta.m) without specifying its path :

This works in matlab, but in octave it currently only worked if the script was in the current directory.

(file #29430, file #29431)

Pantxo Diribarne <pantxo>
Project Member
Fri Oct 18 11:43:05 2013, comment #9:

Yes, sounds good to me.

Mike Miller <mtmiller>
Project Administrator
Fri Oct 18 11:34:32 2013, comment #8:

See my comment #5. The rule could be "always try to run with .m extension first, when none was provided".

If you agree with this I can implement it if you like.

Pantxo Diribarne <pantxo>
Project Member
Fri Oct 18 05:35:06 2013, comment #7:

This doesn't look like an area where we need 100% compatibility. I think we should preserve the ability to 'run' any file, but add the compatible behavior of adding a ".m" to the end of the file name if the user forgot it.

Rik <rik5>
Project Administrator
Fri Oct 18 01:46:15 2013, comment #6:

I had someone check what run does on a "testscript" with different file extensions. If the files testscript, testscript.m, and testscript.txt all exist in the current directory, and each with a call to disp to show their own name:

So what it looks like is Matlab only supports run on .m files, adds the .m extension if it is missing, and refuses to run any non-.m files.

Octave currently supports run on any file, with or without an extension. So how far do we want to go with Matlab compatibility here?

Mike Miller <mtmiller>
Project Administrator
Mon Sep 30 22:39:38 2013, comment #5:

One more octave feature I hadn't noticed ...

I could check matlab does not support running files with no file extension (at leat using "run"). Thus, for matlab compatibility your example should run ~/myscript.m (and maybe warn the user that ~/myscript.m was run, and that he can use source to run the desired file)

If no directory is provided e.g.,
run myscript.m if it exists in the path else run myscript if it exists in the path

This preserves the ability to run files with no file extension in most of the cases without breaking ml compatibility.

Pantxo Diribarne <pantxo>
Project Member
Mon Sep 30 00:33:57 2013, comment #4:

This patch breaks run on files with no file extension, if that is a desired behavior (I think it is).

If I do

If there is a file ~/myscript.m, it should be run. What if there is a file named ~/myscript? What if both files exist, which one should be preferred?

Mike Miller <mtmiller>
Project Administrator
Mon Sep 23 03:18:20 2013, comment #3:

Tested the patch on GNU Octave, version 3.7.6+ (from mercurial repository) under Fedora 17 and confirmed it fixes the missing ".m" extension error:

octave:1> run('~/test.m')
A =

1 1 1
1 1 1
1 1 1
1 1 1

octave:2> run('~/test')
A =

1 1 1
1 1 1
1 1 1
1 1 1

Veronica V <veronica>
Mon Sep 9 21:32:40 2013, comment #2:

Attached is a patch. The ".m" extension is added if none has been found.

(file #29092)

Pantxo Diribarne <pantxo>
Project Member
Thu Aug 29 13:44:58 2013, comment #1:

This is a simple fix. Can you provide a patch?

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Thu Aug 29 08:55:30 2013, original submission:



works in matlab, but not in octave. There, we need


Jan Rüegg <rggjan>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #29430:  bug_39889_2.diff added by pantxo (2kB - text/x-patch)
file #29431:  testrun.m added by pantxo (2kB - text/x-objcsrc)
file #29092:  run_bug39889.patch added by pantxo (642B - text/x-patch)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by veronica (Posted a comment)
  • -unavailable- added by pantxo (Updated the item)
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by rggjan (Submitted the item)
  • -unavailable- added by rggjan

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Oct 21 16:05:41 2013rik5StatusPatch Submitted=>Fixed
    Sun Oct 20 20:48:11 2013pantxoAttached File-=>Added bug_39889_2.diff, #29430
      Attached File-=>Added testrun.m, #29431
    Thu Oct 17 22:16:59 2013rik5StatusNeed Info=>Patch Submitted
    Mon Sep 30 00:40:05 2013mtmillerDependencies-=>bugs #37519 is dependent
    Mon Sep 30 00:33:57 2013mtmillerStatusConfirmed=>Need Info
    Mon Sep 9 21:32:40 2013pantxoAttached File-=>Added run_bug39889.patch, #29092
    Thu Aug 29 13:44:58 2013jordighStatusNone=>Confirmed
    Thu Aug 29 08:55:30 2013rggjanCarbon-Copy-=>Added -unavailable-

    Back to the top

    Powered by Savane 3.1-cleanup1