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

 
 

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

Submitter:  Jan Rüegg <rggjan>
Submitted:  Thu 29 Aug 2013 08:55:30 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 :


run ("scripta")
## or
run ("scripta.m")


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>
Group Member
Fri 18 Oct 2013 11:43:05 AM UTC, comment #9: 

Yes, sounds good to me.

Mike Miller <mtmiller>
Group 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>
Group Member
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>
Group 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:


>> run testscript
In testscript.m
>> run testscript.m
some error message
>> run ./testscript
Inside testscript.m
>> run ./testscript.m
Inside testscript.m
>> run ./testscript.txt
some error message


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>
Group 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")

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>
Group Member
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


run ~/myscript


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>
Group 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>
Group Member
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>
Group Member
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 Files:
   
   
Comment:
   

Attached Files
file #29430:  bug_39889_2.diff added by pantxo (2KiB - text/x-patch)
file #29431:  testrun.m added by pantxo (2KiB - 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
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by veronica (Posted a comment)
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by rggjan (Submitted the item)
  • -email is unavailable- added by rggjan
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-21 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2013-10-20 pantxo Attached File- Added bug_39889_2.diff, #29430
        Attached File- Added testrun.m, #29431
    2013-10-17 rik5 StatusNeed Info Patch Submitted
    2013-09-30 mtmiller Dependencies- bugs #37519 is dependent
    2013-09-30 mtmiller StatusConfirmed Need Info
        Release3.6.4 dev
    2013-09-09 pantxo Attached File- Added run_bug39889.patch, #29092
    2013-08-29 jordigh StatusNone Confirmed
    2013-08-29 rggjan Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code