mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
Merge pull request #8747 from Anonymous-AAA/fix-recursive-cp-backslash
cp: fix recursive cp fails on files with trailing backslashes
This commit is contained in:
parent
2e0e487749
commit
52c71dcac9
2 changed files with 14 additions and 1 deletions
|
|
@ -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)]
|
||||
|
|
@ -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
|
||||
|
|
@ -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:\\")));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue