Compare commits

...

2 commits

2 changed files with 10 additions and 3 deletions

View file

@ -24,9 +24,14 @@ impl Builtin {
let mut args = argv.clone();
let program = args.remove(0);
if program == "cd" {
let function = match program.as_str() {
"cd" => Some(builtins::cd),
_ => None,
};
if function.is_some() {
Ok(Self {
function: builtins::cd,
function: function.unwrap(),
args,
})
} else {

View file

@ -1,7 +1,9 @@
use std::env;
use std::fmt::{Display, Formatter, Result};
use std::path::Path;
pub fn print_error(message: &str) {
let name = std::env::args().next().unwrap();
let name = env::args().next().unwrap_or(String::from("rash"));
let name = Path::new(&name).file_name().unwrap().to_str().unwrap();
eprintln!("{}: {}", name, message);