mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Prevent mv panic again (#6171)
Closes #6170 Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
parent
6b2c7a4c86
commit
cf2e9cf481
@ -119,7 +119,7 @@ impl Command for Mv {
|
|||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
format!(
|
format!(
|
||||||
"Not possible to move {:?} to itself",
|
"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(),
|
"cannot move to itself".into(),
|
||||||
Some(spanned_destination.span),
|
Some(spanned_destination.span),
|
||||||
@ -155,18 +155,17 @@ impl Command for Mv {
|
|||||||
if let Err(error) = result {
|
if let Err(error) = result {
|
||||||
Some(Value::Error { error })
|
Some(Value::Error { error })
|
||||||
} else if verbose {
|
} else if verbose {
|
||||||
let val = if result.expect("Error value when unwrapping mv result") {
|
let val = match result {
|
||||||
format!(
|
Ok(true) => format!(
|
||||||
"moved {:} to {:}",
|
"moved {:} to {:}",
|
||||||
entry.to_string_lossy(),
|
entry.to_string_lossy(),
|
||||||
destination.to_string_lossy()
|
destination.to_string_lossy()
|
||||||
)
|
),
|
||||||
} else {
|
_ => format!(
|
||||||
format!(
|
|
||||||
"{:} not moved to {:}",
|
"{:} not moved to {:}",
|
||||||
entry.to_string_lossy(),
|
entry.to_string_lossy(),
|
||||||
destination.to_string_lossy()
|
destination.to_string_lossy()
|
||||||
)
|
),
|
||||||
};
|
};
|
||||||
Some(Value::String { val, span })
|
Some(Value::String { val, span })
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user