From ad90b6e5f3ecfea5855497b7c84ff037d18872e6 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Thu, 13 Apr 2023 20:34:52 +0800 Subject: [PATCH] `rm`: enable trash flag on android and ios platrofm (#8871) # Description As title, enable trash flag on all platforms make `rm` more portable across different platforms, but `-t` will do nothing. Fixes: #8104 # User-Facing Changes Na # Tests + Formatting It's hard to add tests because we don't run tests for android and ios platforms. # After Submitting --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> --- crates/nu-command/src/filesystem/rm.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/crates/nu-command/src/filesystem/rm.rs b/crates/nu-command/src/filesystem/rm.rs index 3c9eea8e3..126492aa9 100644 --- a/crates/nu-command/src/filesystem/rm.rs +++ b/crates/nu-command/src/filesystem/rm.rs @@ -50,21 +50,15 @@ impl Command for Rm { "filename", SyntaxShape::Filepath, "the path of the file you want to remove", - ); - #[cfg(all( - feature = "trash-support", - not(target_os = "android"), - not(target_os = "ios") - ))] - let sig = sig + ) .switch( "trash", - "move to the platform's trash instead of permanently deleting", + "move to the platform's trash instead of permanently deleting. not used on android and ios", Some('t'), ) .switch( "permanent", - "delete permanently, ignoring the 'always_trash' config option", + "delete permanently, ignoring the 'always_trash' config option. always enabled on android and ios", Some('p'), ); sig.switch("recursive", "delete subdirectories recursively", Some('r')) @@ -169,18 +163,13 @@ fn rm( let rm_always_trash = config.rm_always_trash; - #[cfg(any( - not(feature = "trash-support"), - target_os = "android", - target_os = "ios" - ))] + #[cfg(not(feature = "trash-support"))] { if rm_always_trash { return Err(ShellError::GenericError( "Cannot execute `rm`; the current configuration specifies \ `always_trash = true`, but the current nu executable was not \ - built with feature `trash_support` or trash is not supported on \ - your platform." + built with feature `trash_support`." .into(), "trash required to be true but not supported".into(), Some(span), @@ -189,8 +178,7 @@ fn rm( )); } else if trash { return Err(ShellError::GenericError( - "Cannot execute `rm` with option `--trash`; feature `trash-support` not \ - enabled or trash is not supported on your platform" + "Cannot execute `rm` with option `--trash`; feature `trash-support` not enabled" .into(), "this option is only available if nu is built with the `trash-support` feature" .into(),