summaryrefslogtreecommitdiff
path: root/src/copy.h
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-04-01 16:27:52 +0100
committerPádraig Brady <P@draigBrady.com>2023-04-08 12:11:50 +0100
commitdb28af406f311ac8f78604cc5906613866aecef5 (patch)
tree23c7a3ab85ed425be66ee0ddc8b298769171445d /src/copy.h
parent5891d28edebe229f1a6057275e281b10c1f2247b (diff)
downloadcoreutils-db28af406f311ac8f78604cc5906613866aecef5.tar.gz
cp,mv: add --update=none to always skip existing files
Add --update=none which is equivalent to the --no-clobber behavior from before coreutils 9.2. I.e. existing files are unconditionally skipped, and them not being replaced does not affect the exit status. * src/copy.h [enum Update_type]: A new type to support parameters to the --update command line option. [enum Interactive]: Add I_ALWAYS_SKIP. * src/copy.c: Treat I_ALWAYS_SKIP like I_ALWAYS_NO (-n), except that we don't fail when skipping. * src/system.h (emit_update_parameters_note): A new function to output the description of the new --update parameters. * src/cp.c (main): Parse --update arguments, ensuring that -n takes precedence if specified. (usage): Describe the new option. Also allude that -u is related in the -n description. * src/mv.c: Accept the new --update parameters and update usage() accordingly. * doc/coreutils.texi (cp invocation): Describe the new --update parameters. Also reference --update from the --no-clobber description. (mv invocation): Likewise. * tests/mv/update.sh: Test the new parameters. * NEWS: Mention the new feature. Addresses https://bugs.gnu.org/62572
Diffstat (limited to 'src/copy.h')
-rw-r--r--src/copy.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/copy.h b/src/copy.h
index b02aa2bbb..ea5023cdb 100644
--- a/src/copy.h
+++ b/src/copy.h
@@ -57,11 +57,25 @@ enum Reflink_type
REFLINK_ALWAYS
};
+/* Control how existing destination files are updated. */
+enum Update_type
+{
+ /* Always update.. */
+ UPDATE_ALL,
+
+ /* Update if dest older. */
+ UPDATE_OLDER,
+
+ /* Leave existing files. */
+ UPDATE_NONE,
+};
+
/* This type is used to help mv (via copy.c) distinguish these cases. */
enum Interactive
{
I_ALWAYS_YES = 1,
- I_ALWAYS_NO,
+ I_ALWAYS_NO, /* Skip and fail. */
+ I_ALWAYS_SKIP, /* Skip and ignore. */
I_ASK_USER,
I_UNSPECIFIED
};