From 2f975e913e40616928b8bbcf516773cf9a824d36 Mon Sep 17 00:00:00 2001 From: John Shin Date: Sun, 30 Apr 2023 20:02:53 -0700 Subject: [PATCH] cp: move after help to md file --- src/uu/cp/cp.md | 16 ++++++++++++++++ src/uu/cp/src/cp.rs | 10 +++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/uu/cp/cp.md b/src/uu/cp/cp.md index 5f3cabc18..aadf4006b 100644 --- a/src/uu/cp/cp.md +++ b/src/uu/cp/cp.md @@ -7,3 +7,19 @@ cp [OPTION]... -t DIRECTORY SOURCE... ``` Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. + +## After Help + +Do not copy a non-directory that has an existing destination with the same or newer modification timestamp; +instead, silently skip the file without failing. If timestamps are being preserved, the comparison is to the +source timestamp truncated to the resolutions of the destination file system and of the system calls used to +update timestamps; this avoids duplicate work if several ‘cp -pu’ commands are executed with the same source +and destination. This option is ignored if the -n or --no-clobber option is also specified. Also, if +--preserve=links is also specified (like with ‘cp -au’ for example), that will take precedence; consequently, +depending on the order that files are processed from the source, newer files in the destination may be replaced, +to mirror hard links in the source. which gives more control over which existing files in the destination are +replaced, and its value can be one of the following: + +all This is the default operation when an --update option is not specified, and results in all existing files in the destination being replaced. +none This is similar to the --no-clobber option, in that no files in the destination are replaced, but also skipping a file does not induce a failure. +older This is the default operation when --update is specified, and results in files being replaced if they’re older than the corresponding source file. diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b0c779679..5e791cc3b 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -41,7 +41,9 @@ use uucore::fs::{ canonicalize, paths_refer_to_same_file, FileInformation, MissingHandling, ResolveMode, }; use uucore::update_control::{self, UpdateMode}; -use uucore::{crash, format_usage, help_about, help_usage, prompt_yes, show_error, show_warning}; +use uucore::{ + crash, format_usage, help_about, help_section, help_usage, prompt_yes, show_error, show_warning, +}; use crate::copydir::copy_directory; @@ -232,6 +234,7 @@ pub struct Options { const ABOUT: &str = help_about!("cp.md"); const USAGE: &str = help_usage!("cp.md"); +const AFTER_HELP: &str = help_section!("after help", "cp.md"); static EXIT_ERR: i32 = 1; @@ -310,9 +313,8 @@ pub fn uu_app() -> Command { .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) + .after_help(AFTER_HELP) .infer_long_args(true) - .arg(update_control::arguments::update()) - .arg(update_control::arguments::update_no_args()) .arg( Arg::new(options::TARGET_DIRECTORY) .short('t') @@ -410,6 +412,8 @@ pub fn uu_app() -> Command { .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) .arg(backup_control::arguments::suffix()) + .arg(update_control::arguments::update()) + .arg(update_control::arguments::update_no_args()) .arg( Arg::new(options::REFLINK) .long(options::REFLINK)