-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Shebangs as comments #1772
Comments
It seems pretty harmless to allow the first line to be a shebang. rustx could also filter it out and feed the script to rustc via stdin. |
True, but the drawback to making |
good point |
Agreed. That's how a lot of languages do it (Pascal, OCaml). And it's a pain. Many people have trouble understanding why anyone would like to dot slash their compiled scripts. I guess dot slash is preferable because it standardizes the cli for scripts from different languages. It's POSIX, it's treating every piece of code, compiled, interpreted, whathaveyou, as if it were recombinant bash script, pipable to unix commands and other scripts. |
Another alternative to try, on some platforms, is binfmt: This is what I was trying to remember earlier, @mcandre. |
Yeah, I'd be ok with this. And agree with @Wensleydale that this would be a not-too-awful way of marking a file with "pre-parse" metadata such as "version of rust grammar this file depends on, in order to even parse". A problem we've been discussing elsewhere. |
I'm hearing consensus for "yes, implement as @mcandre suggested". If I'm wrong, yell. |
Fixed by @mmeyerho |
Nice! |
Complete necro, but thank you for implementing this. I just abused it considerably to write a rust “script” that is simultaneously a valid rust program and a valid bash/sh script, primarily just to see if it would be realistic to do so. Much obliged! |
@mqudsi How would I do that using the Rust archive that I extract
|
@mqudsi I figured it out for the test script using |
Can we treat shebangs as comments for those who like doing
#!/usr/bin/env rustx
?It would be nice to compile or interpret the same Rust code as desired, but currently, when you try to compile Rust code with a shebang, you get an ugly syntax error.
hello.rs:
expected output:
actual output:
The text was updated successfully, but these errors were encountered: