[Bro-Dev] Script reorg proposal

Jonathan Siwek jsiwek at ncsa.illinois.edu
Tue Aug 2 08:09:59 PDT 2011

>> I don't think intentional script overshadowing is a use-case that will
>> work as nicely as you want it to if, after the reorganization, most
>> scripts are still as part of a script "package" and referred to
>> internally by a relative path.  e.g. the "base/foo/" package might
>> have a "base/foo/bar.bro" script that's loaded internally via its
>> "__load__.bro" that does "@load ./bar".  That means you should never
>> be able to overshadow that bar.bro.
> Sorry, I'm not sure if I get it. Are you saying that the "@load ./bar"
> directive in __load__.bro is problematic, because, if we search in $HOME
> before the current directory, the wrong bar.bro (in the users home
> directory) is picked rather than the one in base/foo?

No, it's that relative script loading (e.g. @load ./bar) is currently implemented such that it first always searches the directory-of-the-current-script-being-loaded (e.g. the place where __load__.bro lives; $PWD may differ from that).

I guess we could change that, but to me it seems like increasing complexity and decreasing intuitiveness for a situation that will be run into more often by accident rather than intention.  Instead we should probably recommend extending/modifying script behavior through the public API that it advertises.  I think what you're trying to do with script overshadowing is workaround the lack of OO in the language, and if we wanted to solve that, it would be better to address it directly instead of hacking around it?

- Jon

More information about the bro-dev mailing list