From 1b004053acc876da9f82bbe95ae109b08d297412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mo=C3=AFse=20Valvassori?= Date: Wed, 23 Nov 2022 18:42:07 +0100 Subject: [PATCH 1/2] Suspend the progress bar before printing the copied files. --- src/uu/cp/src/cp.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 0dddceab6..5bb596e0b 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1350,7 +1350,13 @@ fn copy_file( } if options.verbose { - println!("{}", context_for(source, dest)); + if let Some(pb) = progress_bar { + pb.suspend(|| { + println!("{}", context_for(source, dest)); + }); + } else { + println!("{}", context_for(source, dest)); + } } // Calculate the context upfront before canonicalizing the path From 8b30ead5884ea2d43361584043980b160b842749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mo=C3=AFse=20Valvassori?= Date: Thu, 24 Nov 2022 06:39:08 +0100 Subject: [PATCH 2/2] add comment to the pregress bar suspension. --- src/uu/cp/src/cp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 5bb596e0b..9664ba66f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1351,6 +1351,7 @@ fn copy_file( if options.verbose { if let Some(pb) = progress_bar { + // Suspend (hide) the progress bar so the println won't overlap with the progress bar. pb.suspend(|| { println!("{}", context_for(source, dest)); });