Skip to content

Commit

Permalink
Use MAIN_SERPARATOR over manual conditional variable assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
just-an-engineer authored and just-an-engineer committed Sep 7, 2024
1 parent cfc82c6 commit b09f50e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/uu/rm/src/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ pub fn remove(files: &[&OsStr], options: &Options) -> bool {
fn handle_dir(path: &Path, options: &Options) -> bool {
let mut had_err = false;

#[cfg(unix)]
let del = "/";
#[cfg(windows)]
let del = "\\";
let del = std::path::MAIN_SEPARATOR;

if path
.to_str()
Expand Down
10 changes: 2 additions & 8 deletions tests/by-util/test_rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,7 @@ fn test_non_utf8() {
fn test_rm_no_del_parent() {
let (at, mut ucmd) = at_and_ucmd!();

#[cfg(not(windows))]
let del = "/";
#[cfg(windows)]
let del = "\\";
let del = std::path::MAIN_SEPARATOR;

at.mkdir("test");
at.mkdir(&format!("test{del}dir"));
Expand All @@ -736,10 +733,7 @@ fn test_rm_no_del_parent() {
fn test_rm_no_del_cur() {
let (at, mut ucmd) = at_and_ucmd!();

#[cfg(not(windows))]
let del = "/";
#[cfg(windows)]
let del = "\\";
let del = std::path::MAIN_SEPARATOR;

at.mkdir("test");
at.touch(&format!("test{del}file"));
Expand Down

0 comments on commit b09f50e

Please sign in to comment.