Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ pub fn path_ends_with_terminator(path: &Path) -> bool {
path.as_os_str()
.as_bytes()
.last()
.is_some_and(|&byte| byte == b'/' || byte == b'\\')
.is_some_and(|&byte| byte == b'/')
}

#[cfg(windows)]
Expand Down Expand Up @@ -1053,6 +1053,7 @@ mod tests {
assert!(path_ends_with_terminator(Path::new("/some/path/")));

// Path ends with a backslash
#[cfg(windows)]
assert!(path_ends_with_terminator(Path::new("C:\\some\\path\\")));

// Path does not end with a terminator
Expand All @@ -1064,6 +1065,7 @@ mod tests {

// Root path
assert!(path_ends_with_terminator(Path::new("/")));
#[cfg(windows)]
assert!(path_ends_with_terminator(Path::new("C:\\")));
}

Expand Down
11 changes: 11 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7079,3 +7079,14 @@ fn test_cp_no_dereference_symlink_with_parents() {
.succeeds();
assert_eq!(at.resolve_link("x/symlink-to-directory"), "directory");
}

#[test]
#[cfg(unix)]
fn test_cp_recursive_files_ending_in_backslash() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir("a");
at.touch("a/foo\\");
ts.ucmd().args(&["-r", "a", "b"]).succeeds();
assert!(at.file_exists("b/foo\\"));
}
Loading