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 _at__at_ -45,7 +45,7 _at__at_ .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 _at__at_ -53,7 +53,7 _at__at_ .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 _at__at_ -116,6 +116,10 _at__at_ 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 _at__at_ -102,7 +102,7 _at__at_ 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; _at__at_ -119,6 +119,12 _at__at_ 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 _at__at_ -429,8 +429,8 _at__at_ { (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 BaldwinReceived on Wed Feb 13 2008 - 17:28:38 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:27 UTC