bugGNU Octave - Bugs: bug #49383, Command-line options counted as as...

 
 

bug #49383: Command-line options counted as as input arguments when started as an application but not when running scripts

Submitted by:  Atri Bhattacharya <badshah400>
Submitted on:  Tue 18 Oct 2016 10:20:32 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: Works For MeAssigned to: None
Originator Name: Atri BhattacharyaOpen/Closed: Closed
Release: 4.2.0-rc2Operating 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 22 Oct 2016 05:28:53 PM UTC, comment #4:

I suggest you read

https://www.gnu.org/software/octave/doc/interpreter/Executable-Octave-Programs.html

which contains a simple example of how to process command line arguments to an Octave program.

Octave scripts do not have arguments. Octave functions do have arguments (using named parameters, nargin, varargin, etc), and Octave programs do have arguments (using argv).

Mike Miller <mtmiller>
Project Administrator
Fri 21 Oct 2016 09:33:10 PM UTC, comment #3:

Thanks, Mike! I am sorry, I do indeed see that the behaviour is consistent across versions. Still, I would very much appreciate if you could let me know of a way to distinguish between input arguments passed to the octave command line and when the script is run from inside octave. Clearly nargin and argv aren't helping.

Thanks!

Atri Bhattacharya <badshah400>
Tue 18 Oct 2016 10:43:36 PM UTC, comment #2:

Thanks for your bug report, but I'm not sure that you're describing a bug rather than a feature or a misunderstanding.

I also don't see any inconsistency between Octave 4.2 and previous versions of Octave wrt nargin and command line arguments. Can you give an example that you believe shows a difference from previous Octave versions?

Yes, running an Octave executable "script" or "program" from the command line, as in

is slightly different from running a script or function in Octave by name, as in

Mike Miller <mtmiller>
Project Administrator
Tue 18 Oct 2016 10:27:11 PM UTC, comment #1:

Sorry, my original discussion got mangled by markup formatting. Here is the latter part of my description:

The results for the various different ways of invoking octave to run mytest.m is as follows:

and so on. In the third case, both the '-q' and '--no-gui' are counted as inputs and end up incrementing nargin. When directly running the script, the command-line args are not counted as such.

Atri Bhattacharya <badshah400>
Tue 18 Oct 2016 10:20:32 PM UTC, original submission:

Octave seems to be counting command-line arguments as inputs (i.e. incrementing nargin) when launched as an application, e.g., not directly running scripts.

For example, consider the following simple script:

mytest.m



The results printed to the screen are different based on how I run this script:

  1. ./mytest.m

0

  1. octave -qf --no-gui mytest.m

0

  1. octave-cli -q

octave:1> mytest
1
octave:2>

This inconsistency can cause issue with scripts depending on nargin, as the results become dependent on how octave is invoked to run the script. This seems a new problem with the 4.2.x branch, I have used nargin dependent scripts with octave 4.0.x and this problem never showed up then.

Atri Bhattacharya <badshah400>

 

(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 mtmiller (Posted a comment)
  • -unavailable- added by badshah400 (Submitted the item)
  •  

    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 22 Oct 2016 05:28:53 PM UTCmtmillerOpen/ClosedOpen=>Closed
    Tue 18 Oct 2016 10:43:36 PM UTCmtmillerStatusNone=>Works For Me

    Back to the top


    Powered by Savane 3.1-cleanup1