bugGNU Octave - Bugs: bug #47451, Return is not respected with input...

 
 

bug #47451: Return is not respected with input redirection

Submitter:  None
Submitted:  Fri 18 Mar 2016 03:04:23 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Wont Fix Assigned to:  None
Originator Name:  SSP Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 19 Mar 2016 10:38:55 PM UTC, comment #2: 

I concur with the description in comment #1.  If you are at the command line interface and type 'return' Octave does nothing because there is nothing to return from.  When invoked with the '< foo.m' syntax it is equivalent to having typed all of the commands one by one into Octave.

And there are lots of workarounds.  Either run


octave foo.m


or change return to exit.

Rik <rik5>
Group administrator
Fri 18 Mar 2016 06:18:48 AM UTC, comment #1: 

Thanks for the bug report. I think this is the expected behavior. The return function returns from a function file or script when invoked as a function or script, either from within the Octave interpreter or when a script is called as an argument on the command line.

Commands that are read from standard input are intended to be the same as entering commands on the interpreter command line, which is not the same as invoking a named script or calling a function.

Other functions also behave differently on standard input vs a script file, e.g. argv, keyboard.

If you use the exit or quit functions rather than return you will get equivalent behavior.

If anything, I would rather see return have no effect except when it's in an actual function definition, but I think it has to return from a called script for Matlab compatibility. It's best to just avoid return except inside of a function body.

Marking won't fix, but leaving open for now in case any one else has a different opinion.

Mike Miller <mtmiller>
Group Member
Fri 18 Mar 2016 03:04:23 AM UTC, original submission:  

The return statement is not respected with input redirection, resulting in inconsistent execution depending on how a script is invoked.

Create a file foo.m like this:

disp('one')
return
disp('two')


Start Octave and invoke foo from the prompt. It prints "one" but not "two".

Quit Octave, and from the shell prompt run "octave <foo.m". That prints both "one" and "two".

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-19 rik5 Open/ClosedOpen Closed
    2016-03-18 mtmiller StatusNone Wont Fix

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code