From f13d5314ffd5a1ea374b0babcc94cd50bf7d4fdf Mon Sep 17 00:00:00 2001 From: aimerlief <152078880+aimerlief@users.noreply.github.com> Date: Sun, 9 Feb 2025 04:47:35 +0900 Subject: [PATCH] cp: fix verbose output order after prompt Fixes: #7285 --- src/uu/cp/src/cp.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 626b65ad63e..0f1a6967b04 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -2271,10 +2271,6 @@ fn copy_file( .into()); } - if options.verbose { - print_verbose_output(options.parents, progress_bar, source, dest); - } - if options.preserve_hard_links() { // if we encounter a matching device/inode pair in the source tree // we can arrange to create a hard link between the corresponding names @@ -2284,6 +2280,11 @@ fn copy_file( .context(format!("cannot stat {}", source.quote()))?, ) { std::fs::hard_link(new_source, dest)?; + + if options.verbose { + print_verbose_output(options.parents, progress_bar, source, dest); + } + return Ok(()); }; } @@ -2334,6 +2335,10 @@ fn copy_file( source_is_stream, )?; + if options.verbose { + print_verbose_output(options.parents, progress_bar, source, dest); + } + // TODO: implement something similar to gnu's lchown if !dest_is_symlink { // Here, to match GNU semantics, we quietly ignore an error