diff --git a/src/main.rs b/src/main.rs index 01debb3..5141a96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use std::{ io::{self, Write}, - path::{Component, Path, PathBuf}, + path::{Component, Path, PathBuf}, process::Command, }; use clap::Parser; @@ -157,7 +157,21 @@ fn main() { println!("exit"); println!("help"); } - _ => println!("psh: {}: command not found", cmd[0]), + _ => { + let path = if cmd[0].starts_with(".") || cmd[0].starts_with("~") || cmd[0].starts_with("/") { + cmd[0].to_string() + } else { + format!("/bin/{}", cmd[0]) + }; + let mut proc = match Command::new(path).spawn() { + Ok(x) => x, + Err(e) => { + println!("psh: {}: {}", cmd[0], e); + continue; + } + }; + let _ = proc.wait().unwrap(); + } } } }