mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
Fix broken removal of sockets (#2629)
* make sort-by fail gracefully if mismatched types are compared * Added a test to check if sorted-by with invalid types exists gracefully * Linter changes * removed redundant pattern matching * Changed the error message * Added a comma after every argument * Changed the test to accomodate the new err messages * Err message for sort-by invalid types now shows the mismatched types * Lints problems * Changed unwrap to expect * Added the -f flag to rm command Now when you a use rm -f there will be no error message, even if the file doesnt actually exist * Lint problems * Fixed the wrong line * Removed println * Spelling mistake * Fix problems when you mv a file into itself * Lint mistakes * Remove unecessary filtering in most cases * Allow the removal of sockets * Conditional compilations to systems without socket
This commit is contained in:
parent
2f1016d44f
commit
b076e375ca
@ -596,9 +596,15 @@ impl Shell for FilesystemShell {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(metadata) = f.symlink_metadata() {
|
if let Ok(metadata) = f.symlink_metadata() {
|
||||||
|
#[cfg(unix)]
|
||||||
|
let is_socket = metadata.file_type().is_socket();
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
let is_socket = false;
|
||||||
|
|
||||||
if metadata.is_file()
|
if metadata.is_file()
|
||||||
|| metadata.file_type().is_symlink()
|
|| metadata.file_type().is_symlink()
|
||||||
|| recursive.item
|
|| recursive.item
|
||||||
|
|| is_socket
|
||||||
|| is_empty()
|
|| is_empty()
|
||||||
{
|
{
|
||||||
let result;
|
let result;
|
||||||
@ -620,7 +626,7 @@ impl Shell for FilesystemShell {
|
|||||||
}
|
}
|
||||||
#[cfg(not(feature = "trash-support"))]
|
#[cfg(not(feature = "trash-support"))]
|
||||||
{
|
{
|
||||||
result = if metadata.is_file() {
|
result = if metadata.is_file() || is_socket {
|
||||||
std::fs::remove_file(&f)
|
std::fs::remove_file(&f)
|
||||||
} else {
|
} else {
|
||||||
std::fs::remove_dir_all(&f)
|
std::fs::remove_dir_all(&f)
|
||||||
|
Loading…
Reference in New Issue
Block a user