fix(interpreter): use correct binary name for argv[0]

This commit is contained in:
2025-07-06 22:41:14 +09:00
parent 14a0d3d6f1
commit be0b928a55

View File

@@ -54,13 +54,12 @@ impl Computer {
fn init_stack(&mut self) -> Result<(), InterpreterError> {
let mut args = Args::parse();
// cant panic, as we would not be here without a valid binary path...
let path = &args.path.unwrap();
// set executable name as argv[0]
let path = &args.path.unwrap();
let filename = Path::new(path).file_name().unwrap().to_str().unwrap();
let mut argv = Vec::from([path.clone()]);
// add the rest of the arguements argv[1], ...
let mut argv = Vec::from([filename.to_string()]);
argv.append(&mut args.argv);
// set default env