From dc0f27a8e8d802c7c5b5efc15e275ac37f3622a4 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 13 Aug 2022 17:48:07 +0200 Subject: [PATCH] added better path handling --- cuddle_cli/src/actions/shell.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cuddle_cli/src/actions/shell.rs b/cuddle_cli/src/actions/shell.rs index add8292..ae042ca 100644 --- a/cuddle_cli/src/actions/shell.rs +++ b/cuddle_cli/src/actions/shell.rs @@ -1,4 +1,4 @@ -use std::process::Command; +use std::{path::PathBuf, process::Command}; use crate::cli::CuddleVariable; @@ -26,7 +26,13 @@ Starting running shell action: {} self.path.clone() ); - let mut process = Command::new(self.path) + let path = PathBuf::from(self.path.clone()); + if !path.exists() { + log::info!("script='{}' not found, aborting", path.to_string_lossy()); + return Err(anyhow::anyhow!("file not found aborting")); + } + + let mut process = Command::new(path) .current_dir(".") .envs(variables.iter().map(|v| { log::trace!("{:?}", v);