Compare commits
2 commits
142d7211bc
...
701643848a
Author | SHA1 | Date | |
---|---|---|---|
701643848a | |||
85a8aa40b4 |
2 changed files with 10 additions and 3 deletions
|
@ -24,9 +24,14 @@ impl Builtin {
|
||||||
let mut args = argv.clone();
|
let mut args = argv.clone();
|
||||||
let program = args.remove(0);
|
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 {
|
Ok(Self {
|
||||||
function: builtins::cd,
|
function: function.unwrap(),
|
||||||
args,
|
args,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
use std::env;
|
||||||
|
use std::fmt::{Display, Formatter, Result};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn print_error(message: &str) {
|
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();
|
let name = Path::new(&name).file_name().unwrap().to_str().unwrap();
|
||||||
|
|
||||||
eprintln!("{}: {}", name, message);
|
eprintln!("{}: {}", name, message);
|
||||||
|
|
Loading…
Reference in a new issue