mirror of
https://github.com/nushell/nushell.git
synced 2025-04-26 06:08:21 +02:00
parent
a724a8fe7d
commit
7336e1df1a
@ -202,6 +202,7 @@ fn rm(
|
|||||||
|
|
||||||
let path = current_dir(engine_state, stack)?;
|
let path = current_dir(engine_state, stack)?;
|
||||||
|
|
||||||
|
let (mut target_exists, mut empty_span) = (false, call.head);
|
||||||
let mut all_targets: HashMap<PathBuf, Span> = HashMap::new();
|
let mut all_targets: HashMap<PathBuf, Span> = HashMap::new();
|
||||||
for target in targets {
|
for target in targets {
|
||||||
if path.to_string_lossy() == target.item
|
if path.to_string_lossy() == target.item
|
||||||
@ -230,6 +231,8 @@ fn rm(
|
|||||||
) {
|
) {
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
for file in files {
|
for file in files {
|
||||||
|
target_exists = true;
|
||||||
|
|
||||||
match file {
|
match file {
|
||||||
Ok(ref f) => {
|
Ok(ref f) => {
|
||||||
// It is not appropriate to try and remove the
|
// It is not appropriate to try and remove the
|
||||||
@ -253,12 +256,17 @@ fn rm(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Target doesn't exists
|
||||||
|
if !target_exists && empty_span.eq(&call.head) {
|
||||||
|
empty_span = target.span;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
Some(call.head),
|
Some(target.span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
))
|
))
|
||||||
@ -270,7 +278,7 @@ fn rm(
|
|||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
"No valid paths".into(),
|
"No valid paths".into(),
|
||||||
"no valid paths".into(),
|
"no valid paths".into(),
|
||||||
Some(call.head),
|
Some(empty_span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user