From de2fe9dd7f2836f89490b822ae4464dab3bc769c Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Mon, 19 Feb 2024 17:45:14 -0700 Subject: Only print command name in error messages Only print out the command name in error messages, rather than printing out the full path to the command. --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 1dc0217..014b882 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,14 +161,20 @@ fn repl(paths: &Vec<&Path>, prompt: &str) { match err.kind() { // Occurs when the user doesn't have read access, or if the +x bit is not set std::io::ErrorKind::PermissionDenied => { - println!("dwvsh: permission denied: trying to fork to {}", &cmd) + println!( + "dwvsh: permission denied: trying to fork to {}", + cmd.split("/").last().unwrap() + ) } // Occurs if a command was removed from the path // If this is the case, refresh the path std::io::ErrorKind::NotFound => { bins = prefresh(&paths); - println!("dwvsh: {}: command not found", cmd); + println!( + "dwvsh: {}: command not found", + cmd.split("/").last().unwrap() + ); } // Otherwise print the OS error -- cgit v1.2.3