untrusted comment: verify with signify key from exoticsilicon.com RWRn5d3Yx35u053/hMWfMVQjK9jOixDooGGH4cuuIjxB4HUvgZA2IjNVGzAjaCMGuPXucrVI7CEgLfx/HkzW1ajiNMqtm0QnEgI= --- cp.c.dist Fri Jun 28 10:34:58 2019 +++ cp.c Mon May 10 14:51:29 2021 @@ -71,7 +73,7 @@ PATH_T to = { to.p_path, "" }; uid_t myuid; -int Rflag, fflag, iflag, pflag, rflag, vflag; +int Rflag, fflag, iflag, pflag, rflag, vflag, sflag; mode_t myumask; enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; @@ -87,8 +89,8 @@ int Hflag, Lflag, Pflag, ch, fts_options, r; char *target; - Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1) + Hflag = Lflag = Pflag = Rflag = sflag = 0; + while ((ch = getopt(argc, argv, "HLPRafiprsv")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -124,6 +126,9 @@ break; case 'r': rflag = 1; + break; + case 's': + sflag = 1; break; case 'v': vflag = 1; --- extern.h.dist Sat Dec 26 15:11:43 2015 +++ extern.h Mon May 10 14:51:24 2021 @@ -40,7 +42,7 @@ extern PATH_T to; extern uid_t myuid; -extern int fflag, iflag, pflag; +extern int fflag, iflag, pflag, sflag; extern mode_t myumask; extern char *__progname; --- cp.1.dist Mon Sep 2 18:18:41 2019 +++ cp.1 Sun Jul 25 19:51:36 2021 @@ -41,14 +42,14 @@ .Nd copy files .Sh SYNOPSIS .Nm cp -.Op Fl afipv +.Op Fl afipsv .Oo .Fl R .Op Fl H | L | P .Oc .Ar source target .Nm cp -.Op Fl afipv +.Op Fl afipsv .Oo .Fl R .Op Fl H | L | P @@ -128,6 +129,10 @@ and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's permissions. +.It Fl s +Supplement existing files in the destination directory. If a file with +the same name as a source file already exists in the target directory, +it is not overwritten, and no copy of that source file is performed. .It Fl R If .Ar source @@ -242,7 +247,7 @@ specification. .Pp The flags -.Op Fl av +.Op Fl asv are extensions to that specification. .Pp Historic versions of the --- utils.c.dist Fri Jun 28 10:34:58 2019 +++ utils.c Wed Jul 28 09:09:03 2021 @@ -78,6 +81,13 @@ fs = entp->fts_statp; + if (sflag==1) { + if (exists) { close(from_fd); return 1; } else { + fprintf (stderr, + "%s doesn't already exist, copying\n",to.p_path); + } + } + /* * In -f (force) mode, we always unlink the destination first * if it exists. Note that -i and -f are mutually exclusive. @@ -326,9 +336,9 @@ usage(void) { (void)fprintf(stderr, - "usage: %s [-afipv] [-R [-H | -L | -P]] source target\n", __progname); + "usage: %s [-afipsv] [-R [-H | -L | -P]] source target\n", __progname); (void)fprintf(stderr, - " %s [-afipv] [-R [-H | -L | -P]] source ... directory\n", + " %s [-afipsv] [-R [-H | -L | -P]] source ... directory\n", __progname); exit(1); }