diff --git a/benches/bench_tar.rs b/benches/bench_tar.rs index 555a1f8..aae35f0 100644 --- a/benches/bench_tar.rs +++ b/benches/bench_tar.rs @@ -186,13 +186,7 @@ fn extract_archive_20_files(bencher: divan::Bencher) { .bench_local_values(|extract_dir| { std::env::set_current_dir(extract_dir.path()).unwrap(); let input = File::open(&archive_path).unwrap(); - operations::extract::extract_archive( - input, - &archive_path, - false, - CompressionMode::None, - ) - .unwrap(); + operations::extract::extract_archive(input, false, CompressionMode::None).unwrap(); }); std::env::set_current_dir(original_dir).unwrap(); } diff --git a/src/uu/tar/src/operations/extract.rs b/src/uu/tar/src/operations/extract.rs index cf465bf..192e04a 100644 --- a/src/uu/tar/src/operations/extract.rs +++ b/src/uu/tar/src/operations/extract.rs @@ -17,7 +17,6 @@ use uucore::error::UResult; /// /// # Arguments /// -/// * `archive_path` - Path to the tar archive to extract /// * `verbose` - Whether to print verbose output during extraction /// /// # Errors @@ -28,7 +27,6 @@ use uucore::error::UResult; /// - Files cannot be extracted due to I/O or permission errors pub fn extract_archive( input: impl Read, - archive_path: &Path, verbose: bool, compression: CompressionMode, ) -> UResult<()> { @@ -36,11 +34,6 @@ pub fn extract_archive( let mut archive = Archive::new(reader); let mut out = BufWriter::new(io::stdout().lock()); - // Extract to current directory - if verbose { - writeln!(out, "Extracting archive: {}", archive_path.display()).map_err(TarError::Io)?; - } - // Members that were refused are reported as they are met; like GNU tar, the // remaining members are still extracted and the exit status records the failure. let mut refused_member = false; diff --git a/src/uu/tar/src/operations/extract_tests.rs b/src/uu/tar/src/operations/extract_tests.rs index 898caff..9332d45 100644 --- a/src/uu/tar/src/operations/extract_tests.rs +++ b/src/uu/tar/src/operations/extract_tests.rs @@ -31,7 +31,7 @@ fn test_extract_archive_with_zstd() { let _guard = crate::operations::TestDirGuard::enter(tempdir.path()); let input = fs::File::open(&archive_path).unwrap(); - let result = extract_archive(input, &archive_path, true, CompressionMode::Zstd); + let result = extract_archive(input, true, CompressionMode::Zstd); result.unwrap(); assert_eq!( diff --git a/src/uu/tar/src/tar.rs b/src/uu/tar/src/tar.rs index 73c8225..78e4101 100644 --- a/src/uu/tar/src/tar.rs +++ b/src/uu/tar/src/tar.rs @@ -162,11 +162,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let compression = explicit_compression.unwrap_or(CompressionMode::Auto); return if archive_path == Path::new("-") { - operations::extract::extract_archive(io::stdin(), archive_path, verbose, compression) + operations::extract::extract_archive(io::stdin(), verbose, compression) } else { let file = File::open(archive_path).map_err(|e| TarError::from_io_error(e, archive_path))?; - operations::extract::extract_archive(file, archive_path, verbose, compression) + operations::extract::extract_archive(file, verbose, compression) }; } diff --git a/tests/by-util/test_tar.rs b/tests/by-util/test_tar.rs index afbc074..293d2fe 100644 --- a/tests/by-util/test_tar.rs +++ b/tests/by-util/test_tar.rs @@ -344,19 +344,13 @@ fn test_extract_verbose() { at.remove("file2.txt"); at.remove("file3.txt"); - // Extract with verbose - let result = new_ucmd!() + // Extract with verbose: like GNU tar, only the member names are printed + new_ucmd!() .arg("-xvf") .arg(at.plus("archive.tar")) .current_dir(at.as_string()) - .succeeds(); - - let stdout = result.stdout_str(); - - // Verify all files are listed in verbose output - assert!(stdout.contains("file1.txt")); - assert!(stdout.contains("file2.txt")); - assert!(stdout.contains("file3.txt")); + .succeeds() + .stdout_only("file1.txt\nfile2.txt\nfile3.txt\n"); // Verify files were extracted assert!(at.file_exists("file1.txt"));