From 5c2a76798718bfabc5ee1f537df6df50be40f10b Mon Sep 17 00:00:00 2001 From: Reilly Wood <26268125+rgwood@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:31:49 -0700 Subject: [PATCH] Better error message for `mv` when file not found (#8586) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #8546. ### Before: ``` > mv foo.txt bar.txt Error: × Invalid file or pattern ╭─[entry #2:1:1] 1 │ mv foo.txt bar.txt · ───┬─── · ╰── invalid file or pattern ╰──── ``` ### After: ``` > mv foo.txt bar.txt Error: × File(s) not found ╭─[entry #2:1:1] 1 │ mv foo.txt bar.txt · ───┬─── · ╰── could not find any files matching this glob pattern ╰──── ``` --- crates/nu-command/src/filesystem/mv.rs | 4 ++-- crates/nu-command/tests/commands/move_/mv.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/filesystem/mv.rs b/crates/nu-command/src/filesystem/mv.rs index 3a4eeb1520..bc68946dcf 100644 --- a/crates/nu-command/src/filesystem/mv.rs +++ b/crates/nu-command/src/filesystem/mv.rs @@ -87,8 +87,8 @@ impl Command for Mv { if sources.is_empty() { return Err(ShellError::GenericError( - "Invalid file or pattern".into(), - "invalid file or pattern".into(), + "File(s) not found".into(), + "could not find any files matching this glob pattern".into(), Some(spanned_source.span), None, Vec::new(), diff --git a/crates/nu-command/tests/commands/move_/mv.rs b/crates/nu-command/tests/commands/move_/mv.rs index acb0a8885d..2e1414a591 100644 --- a/crates/nu-command/tests/commands/move_/mv.rs +++ b/crates/nu-command/tests/commands/move_/mv.rs @@ -203,7 +203,7 @@ fn errors_if_source_doesnt_exist() { cwd: dirs.test(), "mv non-existing-file test_folder/" ); - assert!(actual.err.contains("invalid file or pattern")); + assert!(actual.err.contains("File(s) not found")); }) }