Fri 02 Apr 2010 03:14:27 PM UTC, comment #2:
I've been looking at octave.cc and what currently happens is that the parameter list is truncated only during execution of the script. If --persist is provided octave restores the full args before the prompt appears. In otherwords if testexe.m is changed this way:
#!/usr/local/bin/octave --persist
argv()
Then
$ ./testexe.m test
GNU Octave, version 3.3.50+
Copyright (C) 2009 John W. Eaton and others.
[etc]
ans =
{
[1,1] = test
}
octave:1> argv()
ans =
{
[1,1] = --persist
[2,1] = ./testexe.m
[3,1] = test
}
Currently, I suspect that intern_argv() in octave.cc is just missing logic to truncate the parameter list in the case that there are no extra parameters after the script name. It seems to only modify the argv list if there are more than 1 parameters--the first parameter is the script name.
Initially I thought the behavior was intentional, but my though now now is that it's a bug. If argv() returned the empty list when executing a script file, I think that would be sufficient.
argv("extra") probably isn't needed after the bug-fix. argv("full") could possibly be helpful if someone wanted access to octave's flags while running a script. However, I've personally never really wanted to do that (other than --quiet) and it would be easier to just ask the interpreter directly for its state than to reparse the command line parameters.
I'm testing a fix for the intern_argv bug.
--judd
|