zeek
zeek copied to clipboard
zeek.bif: Add find_in_zeekpath() helper
Relates to #3594. This helper can be used to determine the path that will be used by @load, if at all. Usage example:
@if ( find_in_zeekpath("my-package") != "" )
@load my-package
@endif
Replaces #3615, renaming and adding error on absolute and relative paths.
I still like the idea of
@if ( can_load("the-package") )
@load the-package
@endif
Comparing the return value to "" seems a bit awkward. Is there a use case where the resulting path is useful?
It's just needs a BiF - why not support both?
Comparing the return value to "" seems a bit awkward. Is there a use case where the resulting path is useful?
Yeah, it would look better. It mostly came from the angle that @load
also works for relative paths, too and a can_load()
being over-promising here. As for the return value, my thought was the next possibly question would be what the actual path ended up being (could be interesting if your ZEEKPATH became very complex, or want to determine installation directories based on init-bare.zeek's location or some such tricks), so why not yield that instead.
I do agree that the new helper doesn't make the can_load()
use-case obvious, but that also seemed relatively niche/advanced enough to allow for the != ""
awkwardness. If you/anyone feels much stronger, I'll add it.
It's just needs a BiF - why not support both?
Given find_in_zeekpath()
, can_load()
seemed small enough to be provided by an external script. Though, not sure I understand your comment fully.
I do agree that the new helper doesn't make the can_load() use-case obvious, but that also seemed relatively niche/advanced enough to allow for the != "" awkwardness. If you/anyone feels much stronger, I'll add it.
I've added can_load()
:-)