print function executes index.m in CWD

Ben Abbott bpabbott at mac.com
Fri Sep 5 12:57:35 CDT 2008


On Friday, September 05, 2008, at 12:09PM, "Dmitri A. Sergatskov" <dasergatskov at gmail.com> wrote:
>On Fri, Sep 5, 2008 at 10:27 AM, Ben Abbott <bpabbott at mac.com> wrote:
>...
>>
>> Octave searches its path and runs the first instance of index.m that it finds.
>>
>
>The only index.m I have on my computer is
>
>/usr/share/octave/3.0.1/m/strings/index.m
>
>The file implements function
>octave:1> help index
> -- Function File:  index (S, T)
> -- Function File:  index (S, T, DIRECTION)
>  ...
>
>
>     See also: find, rindex.
>
>/usr/share/octave/3.0.1/m/strings/index.m
>
>This file is obviously in the octave's path.
>
>yet it is not executed at startup, otherwise I would get
>a a message
>
>Invalid call to index.  Correct usage is:
>
> -- Function File:  index (S, T)
> -- Function File:  index (S, T, DIRECTION)
>
>(which I do not).
>
>Having index.m that looks like:
>
>1
>
>(I.e. it just a line with number 1 on it)
>I get:
>
>For information about changes from previous versions, type `news'.
>
>ans =  1
>error: can't perform indexing operations for <unknown type> type
>error: evaluating assignment expression near line 47, column 5
>error: called from `rindex' in file `/usr/share/octave/3.0.1/m/strings/rindex.m'
>error: evaluating assignment expression near line 30, column 10
>(lots of errors deleted)
>...
>error: addpath: expecting all args to be character strings
>error: evaluating if command near line 2231, column 3
>error: called from `pkg:load_packages_and_dependencies' in file
>`/usr/share/octave/3.0.1/m/pkg/pkg.m'
>error: called from `pkg:load_packages' in file
>`/usr/share/octave/3.0.1/m/pkg/pkg.m'
>error: evaluating switch command near line 269, column 3
>error: called from `pkg' in file `/usr/share/octave/3.0.1/m/pkg/pkg.m'
>error: near line 20 of file `/usr/share/octave/3.0.1/m/startup/octaverc'
>
>So I am really baffled.
>
>Dmitri.

Dmitri, 

I'm confused as well. Why should you get the error "Invalid call to index"?

Your comments reminded me of something I had forgotten. If "index" is references prior to your octaverc being run, then the default path has been loaded, but none of the local paths are yet in effect. Which means that "." is  not yet in the path.

Does that explain what you see?

In any event, I just noticed another bug (in the default branch) related to path related functions, which I'll document in a separate email.

Ben







More information about the Bug-octave mailing list