Skip to content
Open
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
3 changes: 1 addition & 2 deletions src/uu/cp/src/copydir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use uucore::fs::{
FileInformation, MissingHandling, ResolveMode, canonicalize, path_ends_with_terminator,
};
use uucore::show;
use uucore::show_error;
use uucore::translate;
use uucore::uio_error;
use walkdir::{DirEntry, WalkDir};
Expand Down Expand Up @@ -513,7 +512,7 @@ pub(crate) fn copy_directory(
}

// Print an error message, but continue traversing the directory.
Err(e) => show_error!("{e}"),
Err(e) => show!(CpError::WalkDirErr(e)),
}
}

Expand Down
23 changes: 23 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7383,3 +7383,26 @@ fn test_cp_recurse_verbose_output_with_symlink_already_exists() {
.no_stderr()
.stdout_is(output);
}

#[test]
fn test_cp_circular_symbolic_links_in_directory() {
let source_dir = "source_dir";
let target_dir = "target_dir";
let (at, mut ucmd) = at_and_ucmd!();

at.mkdir(source_dir);
at.symlink_file(
format!("{source_dir}/a").as_str(),
format!("{source_dir}/b").as_str(),
);
at.symlink_file(
format!("{source_dir}/b").as_str(),
format!("{source_dir}/a").as_str(),
);

ucmd.arg(source_dir)
.arg(target_dir)
.arg("-rL")
.fails_with_code(1)
.stderr_contains("Too many levels of symbolic links");
}
Loading