effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Shebang support

Open jiribenes opened this issue 6 months ago • 2 comments

I think it's fun to have scripts written in Effekt that are directly invokable. To that end, we might want to strip the first few lines starting with #! from source files...

Here's an example:

#!/usr/bin/env effekt

def main() = println("hello")

Here's a different example using effekt-nix:

#!/usr/bin/env nix
#!nix run github:jiribenes/effekt-nix

def main() = println("hello")

jiribenes avatar Jun 18 '25 19:06 jiribenes

rustc seems to just skip lines starting with #! at the beginning of the file: https://github.com/rust-lang/rust/blob/f9c15f40fbd7b4ba1baea6fb89551274047e17b3/compiler/rustc_parse/src/lexer/mod.rs#L49-L59

jiribenes avatar Jun 18 '25 20:06 jiribenes

This would be even more useful if we wouldn't recompile the standard library every time :)

b-studios avatar Jun 18 '25 21:06 b-studios