Shebang fails with Rhai engine
tamasfe opened this issue · 3 comments
I pulled in the rhai engine in order to test the compliance of the parser (and later the HIR), but Engine::compile(...)
seems to fail if the scripts starts with a shebang line with the error of #!
being reserved.
According to the book, eval_file
supports shebangs, is this a bug or do I need to strip the line manually before passing the script to compile
?
I'm not sure if I should open this in the Rhai repo.
Yes, the shebang is only handled when reading script files. You'd need to strip it off manually if working with a script in string form.
It may be useful to handle it globally, but it may introduce subtle errors where multiple pieces of texts are joined together in order to form a single script. For example:
Script 1:
print(`This is a shebang:
Script 2:
#! /usr/bin/rhai-run
`);
Rhai currently allows you to specify a slice of strings to join together as a single script via Engine::compile_scripts_with_scope
.
What do you think?
Alright thanks, it makes perfect sense. I'll just strip it then.