fix(interpreter): load prog name as argv[0]

This commit is contained in:
2025-07-04 15:05:18 +09:00
parent 6c593a8d1e
commit 89634e50c4

View File

@@ -1,5 +1,6 @@
use clap::Parser;
use core::fmt;
use std::path::Path;
use crate::{
Args,
@@ -50,9 +51,12 @@ impl Computer {
}
fn init_stack(&mut self) -> Result<(), InterpreterError> {
let args = Args::parse();
let argv = args.argv;
let argc = argv.len() + 1;
let mut args = Args::parse();
let path = &args.path.unwrap();
let filename = Path::new(path).file_name().unwrap().to_str().unwrap();
let mut argv = Vec::from([filename.to_string()]);
argv.append(&mut args.argv);
let argc = argv.len();
let mut argv_ptrs = Vec::new();
let envs = Vec::from(["PATH=/usr:/usr/bin".to_string()]);