mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
Add more '/' checks to rm
This commit is contained in:
parent
d08d8c8029
commit
2021a55775
1 changed files with 10 additions and 4 deletions
14
rm/rm.rs
14
rm/rm.rs
|
@ -116,7 +116,7 @@ fn remove_files(files: &[~str], force: bool, interactive: InteractiveMode, one_f
|
|||
}).inside(|| {
|
||||
fs::rmdir(&file);
|
||||
});
|
||||
} else if dir {
|
||||
} else if dir && (*filename != ~"/" || !preserve_root) {
|
||||
io_error::cond.trap(|_| {
|
||||
writeln!(&mut stderr() as &mut Writer,
|
||||
"Could not remove directory '{}'", *filename);
|
||||
|
@ -124,9 +124,15 @@ fn remove_files(files: &[~str], force: bool, interactive: InteractiveMode, one_f
|
|||
fs::rmdir(&file);
|
||||
});
|
||||
} else {
|
||||
writeln!(&mut stderr() as &mut Writer,
|
||||
"Could not remove directory '{}' (did you mean to pass '-r'?)",
|
||||
*filename);
|
||||
if recursive {
|
||||
writeln!(&mut stderr() as &mut Writer,
|
||||
"Could not remove directory '{}'",
|
||||
*filename);
|
||||
} else {
|
||||
writeln!(&mut stderr() as &mut Writer,
|
||||
"Could not remove directory '{}' (did you mean to pass '-r'?)",
|
||||
*filename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
io_error::cond.trap(|_| {
|
||||
|
|
Loading…
Reference in a new issue