I’m currently writing alots of glue code in bash.
Is there anyway to do
#!style scripting with Rust?
I’m okay with the # of lines of code tripling, if, in exchange I get highly maintainable Rust code instead of Bash code (which I find difficult to reason about,)
The path after
#! needs to be an absolute path, but in Rust the only thing that may follow
[, so I don’t think so. You might be able to do something with the Linux
binfmt system (if your OS is Linux). But wouldn’t you want to use cargo as well?
Have you seen cargo-script?
@jethrogb : You’re right, the
#! requirement makes no sense. For some reason, I just thought
#!/bin/run-rust (for some magical
run-rust) and forgot that the entire file had to be a valid *.rs file.
@Michael-F-Bryan : Thanks, Cargo-Script looks like what I want.
Other suggestions welcome!
#! at the beginning of the file which isn’t followed by
[ is considered a comment.