diff --git a/duckscript_sdk/src/sdk/std/fs/rm/mod.rs b/duckscript_sdk/src/sdk/std/fs/rm/mod.rs index 69ce94d..3a4a02f 100755 --- a/duckscript_sdk/src/sdk/std/fs/rm/mod.rs +++ b/duckscript_sdk/src/sdk/std/fs/rm/mod.rs @@ -49,7 +49,7 @@ impl Command for CommandImpl { let result = if !path.exists() { Ok(()) } else if path.is_file() { - fs::remove_file(&arguments[0]) + fs::remove_file(&path) } else if recursive { fs::remove_dir_all(&path) } else { diff --git a/duckscript_sdk/src/sdk/std/fs/rm/mod_test.rs b/duckscript_sdk/src/sdk/std/fs/rm/mod_test.rs index 4e51250..823a3a4 100644 --- a/duckscript_sdk/src/sdk/std/fs/rm/mod_test.rs +++ b/duckscript_sdk/src/sdk/std/fs/rm/mod_test.rs @@ -56,6 +56,22 @@ fn run_path_is_file() { assert!(!path.exists()); } +#[test] +fn run_path_is_file_and_with_flag() { + let path = Path::new("./target/_duckscript/rm/file_with_flag.txt"); + let result = ensure_exists("./target/_duckscript/rm/file_with_flag.txt"); + assert!(result.is_ok()); + assert!(path.exists()); + + test::run_script_and_validate( + vec![create("")], + "out = rm -r ./target/_duckscript/rm/file_with_flag.txt", + CommandValidation::Match("out".to_string(), "true".to_string()), + ); + + assert!(!path.exists()); +} + #[test] fn run_path_recursive() { let path = Path::new("./target/_duckscript/rm/recursive/file.txt");