From be0b928a55e2ed5888ad7642fd1ab811db24dfc0 Mon Sep 17 00:00:00 2001 From: Marco Thomas Date: Sun, 6 Jul 2025 22:41:14 +0900 Subject: [PATCH] fix(interpreter): use correct binary name for argv[0] --- src/interpreter/computer.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/interpreter/computer.rs b/src/interpreter/computer.rs index 1d7f3a5..158f14d 100644 --- a/src/interpreter/computer.rs +++ b/src/interpreter/computer.rs @@ -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