strange behaviour when running a script via "run"

John W. Eaton jwe at octave.org
Tue Apr 21 14:42:52 CDT 2009


On 21-Apr-2009, John W. Eaton wrote:

| On 19-Apr-2009, Carlo de Falco wrote:
| 
| | Hi,
| | 
| | I have the following line in my .octaverc to load the sundials toolbox:
| | 
| | run /opt/sundials/2.3.0/sundialsTB/startup_STB.m
| | 
| | Since I built and installed the current mercurial tip on OSX this has  
| | stopped working,
| | I believe this is due to a strange behaviour when running scripts with  
| | the "run" command.
| | 
| | For example with the following very simple script:
| | 
| | ---------------------------------------------------
| |  >> type startup_STB
| | startup_STB is the user-defined function defined from: /Users/carlo/ 
| | Desktop/test/startup_STB.m
| | 
| | stb_path = '/opt/sundials/2.3.0';
| | stb = fullfile(stb_path,'sundialsTB');
| | printf(["stb=" stb "\n"]);
| | printf(["stb=" stb "\n"]);
| | ---------------------------------------------------
| | 
| | I get
| | 
| | ---------------------------------------------------
| |  >> version
| | ans = 3.1.55
| |  >> run startup_STB.m
| | stb=/opt/sundials/2.3.0/sundialsTB
| | `stb' undefined near line 4 column 16
| | error: called from `startup_STB' in file /Users/carlo/Desktop/test/ 
| | startup_STB.m near line 4, column 1
| | error: called from:
| | error:   /Users/carlo/Desktop/OF/octave/octave-hg/scripts/ 
| | miscellaneous/run.m at line 53, column 7
| | ---------------------------------------------------
| | 
| | i.e. the variable "stb" exists when referenced in the first printf  
| | command but it's undefined when printf is called the second time.
| | If the script is launched directly, everything seems to work fine
| | 
| | ---------------------------------------------------
| |  >> startup_STB
| | /opt/sundials/2.3.0/sundialsTB
| | /opt/sundials/2.3.0/sundialsTB
| | ---------------------------------------------------
| 
| The following patch should fix the problem, but I haven't checked it
| in yet because I'd like to think more about whether there is a better
| way to handle scope changes like this.

I checked in a different patch that eliminates the duplication in
scoping information maintained in the call stack and the symbol table.

  http://hg.savannah.gnu.org/hgweb/octave/rev/c6463412aebb

jwe


More information about the Bug-octave mailing list