From fe4da2b8e55f7a45085cf7456f65b055b52139d8 Mon Sep 17 00:00:00 2001 From: David Matos Date: Sun, 18 Sep 2022 20:25:14 +0200 Subject: [PATCH 1/2] cp: modify archive flag to copy dir contents rather than dir --- src/uu/cp/src/copydir.rs | 2 +- tests/by-util/test_cp.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index a89bd8537..c312b7cbb 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -93,7 +93,7 @@ impl<'a> Context<'a> { fn new(root: &'a Path, target: &'a Path) -> std::io::Result { let current_dir = env::current_dir()?; let root_path = current_dir.join(root); - let root_parent = if target.exists() { + let root_parent = if target.exists() && !root.to_str().unwrap().ends_with("/.") { root_path.parent().map(|p| p.to_path_buf()) } else { Some(root_path) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index e6e8a6ba2..eec6b4536 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -2532,3 +2532,14 @@ fn test_src_base_dot() { .no_stdout(); assert!(!at.dir_exists("y/x")); } + +#[test] +#[cfg(not(windows))] +fn test_cp_archive_on_directory_ending_dot() { + let (at, mut ucmd) = at_and_ucmd!(); + at.mkdir("dir1"); + at.mkdir("dir2"); + at.touch("dir1/file"); + ucmd.args(&["-a", "dir1/.", "dir2"]).succeeds(); + assert!(at.file_exists("dir2/file")); +} From 351be7f47888d727e63cfc1afccf66e44f7fefac Mon Sep 17 00:00:00 2001 From: Zan Baldwin Date: Sun, 26 Feb 2023 13:13:51 +0100 Subject: [PATCH 2/2] uptime: correctly calculate boot-time --- src/uu/uptime/src/uptime.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index d13445f60..3a561f419 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -115,8 +115,8 @@ fn process_utmpx() -> (Option, usize) { USER_PROCESS => nusers += 1, BOOT_TIME => { let dt = line.login_time(); - if dt.second() > 0 { - boot_time = Some(dt.second() as time_t); + if dt.unix_timestamp() > 0 { + boot_time = Some(dt.unix_timestamp() as time_t); } } _ => continue,