Is it possible to get the path of a .blend file from within OSL? I'm aware of how to do this with Python, that won't solve the issue in an ideal way for me. Introducing Python is uncomfortably outside of the scope of what I'm writing.
I'm attempting to use a texture lookup from within OSL, as part of a tutorial I'm creating; but the default working directory is the same as Blender's. That makes it very difficult to write portable code that will work on any other machine--I can't use relative paths. I'm really trying to ensure that the tutorial file will immediately work on 2.92, on any machine, out-of-the-box.
Is there a manner in which OSL can retrieve the path to the current .blend file internally?
OSL itself doesn't provide any facilities to access files relative to the .blend file.
However, when passing a 'string' into an OSL script node, Blender automatically assumes that the string represents a filename. As with other filenames in Blender, prefixing the filename with '//' will indicate a path relative to the saved .blend file.
Therefore, in order to get the filepath to the .blend in an OSL shader simply add a 'string' input and set its value (within the node field) to '//'.