diff --git a/crates/nu-command/src/filesystem/mv.rs b/crates/nu-command/src/filesystem/mv.rs index 1ddd3dc828..3c0a3e1080 100644 --- a/crates/nu-command/src/filesystem/mv.rs +++ b/crates/nu-command/src/filesystem/mv.rs @@ -119,7 +119,7 @@ impl Command for Mv { return Err(ShellError::GenericError( format!( "Not possible to move {:?} to itself", - filename.file_name().expect("Invalid file name") + filename.file_name().unwrap_or(filename.as_os_str()) ), "cannot move to itself".into(), Some(spanned_destination.span), @@ -155,18 +155,17 @@ impl Command for Mv { if let Err(error) = result { Some(Value::Error { error }) } else if verbose { - let val = if result.expect("Error value when unwrapping mv result") { - format!( + let val = match result { + Ok(true) => format!( "moved {:} to {:}", entry.to_string_lossy(), destination.to_string_lossy() - ) - } else { - format!( + ), + _ => format!( "{:} not moved to {:}", entry.to_string_lossy(), destination.to_string_lossy() - ) + ), }; Some(Value::String { val, span }) } else {