Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tl removes shebang in scripts #646

Closed
nagolove opened this issue Apr 1, 2023 · 3 comments
Closed

tl removes shebang in scripts #646

nagolove opened this issue Apr 1, 2023 · 3 comments

Comments

@nagolove
Copy link

nagolove commented Apr 1, 2023

Hello! I use some Lua files as system scripts with executable bits and shebang at first line.

#!/usr/bin/env lua
some_code

But tl compiler remove this first line. Could this behavior be fixed to leave this line alone in generated file?

@hishamhm
Copy link
Member

hishamhm commented Nov 7, 2023

You can use

#!/usr/bin/env -S tl run

as your shebang line and keep the script code in Teal. Does that solve your problem?

I'm a bit torn about automatically preserving the shebang line upon compilation because if a Teal script contains a hashbang pointing to tl as indicated above, compiling it to Lua would render the shebang incorrect (and it's not feasible to automatically guess what the correct Lua incantation should be). Maybe the right answer would be to just cop out and add a compiler flag...

@lenscas
Copy link
Contributor

lenscas commented Nov 7, 2023

maybe check if the shebang contains lua (or perhaps do it the other way and check if it doesn't include tl) and preserve it if it does. Then you can also emit a warning if it contains tl instead?

It won't be perfect (not by a long shot) but might be correct for enough cases to be worth it?

@nagolove
Copy link
Author

Thanks all contributors for satisfying feature request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants