fornwall / rust-script

Run Rust files and expressions as scripts without any setup or compilation step.
https://rust-script.org
Apache License 2.0
1.2k stars 41 forks source link

First CLI Argument should contain name of script instead of compiled binary #113

Closed ChristianS99 closed 11 months ago

ChristianS99 commented 11 months ago
#!/usr/bin/env rust-script
use std::env;

fn main() {
  let args: Vec<String> = env::args().collect();
  println!("{:?}", args);
}

executing this with rust-script prints out ["/home/chriss/.cache/rust-script/binaries/release/rust-script-test_83ff7425da238fd28ad88049"] instead, I would expect "./rust-script-test.rs", or whatever the script is called with.

Would this be even possible?

Maybe related: ps a also shows script like 879316 pts/5 S+ 0:00 /home/chriss/.cache/rust-script/binaries/release/rust-script-test_83ff7425da238fd28ad88049 instead of the script name. Can this be changed? Should this be a separate issue?

fornwall commented 11 months ago

The PR (#114) has now been released in version 0.32.0 of rust-script - thanks!