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 29 Aug 2013 08:55:30 AM UTC  
 
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 21 Oct 2013 04:05:41 PM UTC, 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 20 Oct 2013 08:48:11 PM UTC, 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>
Fri 18 Oct 2013 11:43:05 AM UTC, comment #9:

Yes, sounds good to me.

Mike Miller <mtmiller>
Project Member
Fri 18 Oct 2013 11:34:32 AM UTC, 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>
Fri 18 Oct 2013 05:35:06 AM UTC, 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 18 Oct 2013 01:46:15 AM UTC, 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 Member
Mon 30 Sep 2013 10:39:38 PM UTC, 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>
Mon 30 Sep 2013 12:33:57 AM UTC, 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 Member
Mon 23 Sep 2013 03:18:20 AM UTC, 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 09 Sep 2013 09:32:40 PM UTC, comment #2:

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

(file #29092)

Pantxo Diribarne <pantxo>
Thu 29 Aug 2013 01:44:58 PM UTC, comment #1:

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

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

This

run('~/sources/vlfeat/toolbox/vl_setup')

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

run('~/sources/vlfeat/toolbox/vl_setup.m')

Jan Rüegg <rggjan>

 

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

Attach File(s):
   
   
Comment:
   

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

Digest:
   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 21 Oct 2013 04:05:41 PM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sun 20 Oct 2013 08:48:11 PM UTCpantxoAttached File-=>Added bug_39889_2.diff, #29430
      Attached File-=>Added testrun.m, #29431
    Thu 17 Oct 2013 10:16:59 PM UTCrik5StatusNeed Info=>Patch Submitted
    Mon 30 Sep 2013 12:40:05 AM UTCmtmillerDependencies-=>bugs #37519 is dependent
    Mon 30 Sep 2013 12:33:57 AM UTCmtmillerStatusConfirmed=>Need Info
      Release3.6.4=>dev
    Mon 09 Sep 2013 09:32:40 PM UTCpantxoAttached File-=>Added run_bug39889.patch, #29092
    Thu 29 Aug 2013 01:44:58 PM UTCjordighStatusNone=>Confirmed
    Thu 29 Aug 2013 08:55:30 AM UTCrggjanCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup