Gestion des erreurs : seul le nom du programme est affiché

This commit is contained in:
Ahurac 2023-12-13 19:33:18 +01:00
parent 62e34a9f46
commit b0a89b688f

View file

@ -1,7 +1,14 @@
use std::env;
use std::path::Path;
fn error(message: &str) {
eprintln!("{}: {}", env::args().next().unwrap(), message);
let argv0: String = env::args().next().unwrap();
let program_name = Path::new(&argv0)
.file_name()
.unwrap()
.to_str()
.unwrap();
eprintln!("{}: {}", program_name, message);
}
pub fn command_not_found(command: &String) -> i32 {