diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2019-01-28 18:58:43 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2019-01-28 18:58:43 +0000 |
commit | ca2b77d41bf9c6b86107ae04354fc3c869d060da (patch) | |
tree | 8936ac5448690ec3d75c1b88dd0ec4e192601691 /bin/cp | |
parent | 7ee95d42836ee9d4d3ec2b34cb6e601c78e2280b (diff) |
Implement cp -a ("archive" mode)
Not standard, but supported at least by GNU cp, IllumOS, NetBSD,
FreeBSD, DragonflyBSD. No need to be gratuitously different. This
should also allow us to drop patches in ~10 ports.
Based on an initial diff by benno@ with input from sthen@ and jmc@
ok benno@ danj@ sthen@ martijn@ deraadt@
Diffstat (limited to 'bin/cp')
-rw-r--r-- | bin/cp/cp.1 | 18 | ||||
-rw-r--r-- | bin/cp/cp.c | 10 | ||||
-rw-r--r-- | bin/cp/utils.c | 6 |
3 files changed, 22 insertions, 12 deletions
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1 index 87bc14bc923..9565ad49108 100644 --- a/bin/cp/cp.1 +++ b/bin/cp/cp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cp.1,v 1.39 2017/06/28 06:24:38 jmc Exp $ +.\" $OpenBSD: cp.1,v 1.40 2019/01/28 18:58:42 jca Exp $ .\" $NetBSD: cp.1,v 1.9 1995/07/25 19:36:45 jtc Exp $ .\" .\" Copyright (c) 1989, 1990, 1993, 1994 @@ -33,7 +33,7 @@ .\" .\" @(#)cp.1 8.3 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: June 28 2017 $ +.Dd $Mdocdate: January 28 2019 $ .Dt CP 1 .Os .Sh NAME @@ -41,14 +41,14 @@ .Nd copy files .Sh SYNOPSIS .Nm cp -.Op Fl fipv +.Op Fl afipv .Oo .Fl R .Op Fl H | L | P .Oc .Ar source target .Nm cp -.Op Fl fipv +.Op Fl afipv .Oo .Fl R .Op Fl H | L | P @@ -74,6 +74,10 @@ detects an attempt to copy a file to itself, the copy will fail. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Archive mode. +Same as +.Fl RpP . .It Fl f For each existing destination pathname, remove it and create a new file, without prompting for confirmation, @@ -237,9 +241,9 @@ utility is compliant with the .St -p1003.1-2008 specification. .Pp -The flag -.Op Fl v -is an extension to that specification. +The flags +.Op Fl av +are extensions to that specification. .Pp Historic versions of the .Nm diff --git a/bin/cp/cp.c b/bin/cp/cp.c index c2f947a721e..c0a0d63dbeb 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cp.c,v 1.51 2018/09/07 13:46:33 martijn Exp $ */ +/* $OpenBSD: cp.c,v 1.52 2019/01/28 18:58:42 jca Exp $ */ /* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */ /* @@ -88,7 +88,7 @@ main(int argc, char *argv[]) char *target; Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1) + while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -105,6 +105,12 @@ main(int argc, char *argv[]) case 'R': Rflag = 1; break; + case 'a': + Rflag = 1; + pflag = 1; + Pflag = 1; + Hflag = Lflag = 0; + break; case 'f': fflag = 1; iflag = 0; diff --git a/bin/cp/utils.c b/bin/cp/utils.c index dc86deb17b7..2275c127b76 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.46 2018/09/07 13:46:33 martijn Exp $ */ +/* $OpenBSD: utils.c,v 1.47 2019/01/28 18:58:42 jca Exp $ */ /* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */ /*- @@ -326,9 +326,9 @@ void usage(void) { (void)fprintf(stderr, - "usage: %s [-fipv] [-R [-H | -L | -P]] source target\n", __progname); + "usage: %s [-afipv] [-R [-H | -L | -P]] source target\n", __progname); (void)fprintf(stderr, - " %s [-fipv] [-R [-H | -L | -P]] source ... directory\n", + " %s [-afipv] [-R [-H | -L | -P]] source ... directory\n", __progname); exit(1); } |