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

 
 

bug #47451: Return is not respected with input redirection

Submitted by:  None
Submitted on:  Fri 18 Mar 2016 03:04:23 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Other
Status: Wont FixAssigned to: None
Originator Name: SSPOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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

or change return to exit.

Rik <rik5>
Project 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>
Project Administrator
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:

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 19 Mar 2016 10:38:55 PM UTCrik5Open/ClosedOpen=>Closed
    Fri 18 Mar 2016 06:18:48 AM UTCmtmillerStatusNone=>Wont Fix

    Back to the top


    Powered by Savane 3.1-cleanup1