tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Proposal for cp -a



I propose to add option -a to cp(1).
FreeBSD (since about 7.1), Linux and some other platforms have it,
and I think it is very useful.

Patch is in attachment.

Index: cp.1
===================================================================
RCS file: /pub/NetBSD-CVS/src/bin/cp/cp.1,v
retrieving revision 1.30
diff -u -r1.30 cp.1
--- cp.1        26 Oct 2007 16:31:16 -0000      1.30
+++ cp.1        20 Dec 2010 21:12:01 -0000
@@ -45,7 +45,7 @@
 .Op Fl H | Fl L | Fl P
 .Oc
 .Op Fl f | i
-.Op Fl Npv
+.Op Fl aNpv
 .Ar source_file target_file
 .Nm cp
 .Oo
@@ -53,7 +53,7 @@
 .Op Fl H | Fl L | Fl P
 .Oc
 .Op Fl f | i
-.Op Fl Npv
+.Op Fl aNpv
 .Ar source_file ... target_directory
 .Sh DESCRIPTION
 In the first synopsis form, the
@@ -100,6 +100,10 @@
 If the
 .Fl R
 option is specified, all symbolic links are followed.
+.It Fl a
+Archive mode.
+Same as
+.Fl RpP .
 .It Fl N
 When used with
 .Fl p ,
Index: cp.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/bin/cp/cp.c,v
retrieving revision 1.53
diff -u -r1.53 cp.c
--- cp.c        8 Oct 2009 20:36:41 -0000       1.53
+++ cp.c        20 Dec 2010 21:12:01 -0000
@@ -106,7 +106,7 @@
        (void)setlocale(LC_ALL, "");
 
        Hflag = Lflag = Pflag = Rflag = 0;
-       while ((ch = getopt(argc, argv, "HLNPRfiprv")) != -1) 
+       while ((ch = getopt(argc, argv, "HLNPRfaiprv")) != -1) 
                switch (ch) {
                case 'H':
                        Hflag = 1;
@@ -126,6 +126,12 @@
                case 'R':
                        Rflag = 1;
                        break;
+               case 'a':
+                       Pflag = 1;
+                       pflag = 1;
+                       Rflag = 1;
+                       Hflag = Lflag = 0;
+                       break;
                case 'f':
                        fflag = 1;
                        iflag = 0;
Index: utils.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/bin/cp/utils.c,v
retrieving revision 1.36
diff -u -r1.36 utils.c
--- utils.c     25 Oct 2010 08:19:47 -0000      1.36
+++ utils.c     20 Dec 2010 21:12:01 -0000
@@ -367,8 +367,8 @@
 usage(void)
 {
        (void)fprintf(stderr,
-           "usage: %s [-R [-H | -L | -P]] [-f | -i] [-Npv] src target\n"
-           "       %s [-R [-H | -L | -P]] [-f | -i] [-Npv] src1 ... srcN 
directory\n",
+           "usage: %s [-R [-H | -L | -P]] [-f | -i] [-aNpv] src target\n"
+           "       %s [-R [-H | -L | -P]] [-f | -i] [-aNpv] src1 ... srcN 
directory\n",
            getprogname(), getprogname());
        exit(1);
        /* NOTREACHED */
-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index