From c6436eb32f7f0042b797d5ff2f44454aec9d505a Mon Sep 17 00:00:00 2001 From: nibon7 Date: Fri, 21 Oct 2022 22:42:29 +0800 Subject: [PATCH] rm: don't update target_exists every time in the loop (#6837) --- crates/nu-command/src/filesystem/rm.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/nu-command/src/filesystem/rm.rs b/crates/nu-command/src/filesystem/rm.rs index d56bd50cd9..05e3828b9e 100644 --- a/crates/nu-command/src/filesystem/rm.rs +++ b/crates/nu-command/src/filesystem/rm.rs @@ -231,10 +231,12 @@ fn rm( ) { Ok(files) => { for file in files { - target_exists = true; - match file { Ok(ref f) => { + if !target_exists { + target_exists = true; + } + // It is not appropriate to try and remove the // current directory or its parent when using // glob patterns.