Date: Wed, 13 Feb 2008 11:53:04 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-current@freebsd.org Cc: David Frascone <frasconebulk@gmail.com> Subject: Re: Small patch to add -a to cp Message-ID: <200802131153.04293.jhb@freebsd.org> In-Reply-To: <681a18e40802111347i3c23c34cve3c1d08b2eaeff0f@mail.gmail.com> References: <681a18e40802111347i3c23c34cve3c1d08b2eaeff0f@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 11 February 2008 04:47:44 pm David Frascone wrote:
> This small patch adds the -a (archive) flag to cp. Personally, I use cp -a
> all the time, and I miss it on BSD. This makes cp share the common -a flag
> with rsync and other file manipulation utilities.
>
> Comments, flames, etc welcome.
I have this patch from the last time this came up. It maps -a to -RpP rather
than -rpP though. Since -r won't preserve symlinks but copy their contents, I
think -RpP is probably the better default.
Index: cp.1
===================================================================
RCS file: /usr/cvs/src/bin/cp/cp.1,v
retrieving revision 1.39
diff -u -r1.39 cp.1
--- cp.1 2 Nov 2006 19:10:05 -0000 1.39
+++ cp.1 16 Mar 2007 03:19:51 -0000
@@ -45,7 +45,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
-.Op Fl lpv
+.Op Fl alpv
.Ar source_file target_file
.Nm
.Oo
@@ -53,7 +53,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
-.Op Fl lpv
+.Op Fl alpv
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
@@ -116,6 +116,10 @@
or
.Xr pax 1
instead.
+.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
Index: cp.c
===================================================================
RCS file: /usr/cvs/src/bin/cp/cp.c,v
retrieving revision 1.59
diff -u -r1.59 cp.c
--- cp.c 26 Dec 2007 08:32:20 -0000 1.59
+++ cp.c 10 Jan 2008 16:03:38 -0000
@@ -102,7 +102,7 @@
char *target;
Hflag = Lflag = Pflag = 0;
- while ((ch = getopt(argc, argv, "HLPRfilnprv")) != -1)
+ while ((ch = getopt(argc, argv, "HLPRafilnprv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -119,6 +119,12 @@
case 'R':
Rflag = 1;
break;
+ case 'a':
+ Pflag = 1;
+ pflag = 1;
+ Rflag = 1;
+ Hflag = Lflag = 0;
+ break;
case 'f':
fflag = 1;
iflag = nflag = 0;
Index: utils.c
===================================================================
RCS file: /usr/cvs/src/bin/cp/utils.c,v
retrieving revision 1.52
diff -u -r1.52 utils.c
--- utils.c 7 Oct 2006 12:14:50 -0000 1.52
+++ utils.c 16 Mar 2007 03:19:51 -0000
@@ -429,8 +429,8 @@
{
(void)fprintf(stderr, "%s\n%s\n",
-"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-lpv] source_file target_file",
-" cp [-R [-H | -L | -P]] [-f | -i | -n] [-lpv] source_file ... "
+"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpv] source_file target_file",
+" cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpv] source_file ... "
"target_directory");
exit(EX_USAGE);
}
--
John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802131153.04293.jhb>
