From owner-freebsd-current@FreeBSD.ORG Wed Feb 13 18:28:38 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51A3716A419 for ; Wed, 13 Feb 2008 18:28:38 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id DB90513C461 for ; Wed, 13 Feb 2008 18:28:37 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8s) with ESMTP id 231815169-1834499 for multiple; Wed, 13 Feb 2008 13:26:36 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m1DISMaj076706; Wed, 13 Feb 2008 13:28:30 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Wed, 13 Feb 2008 11:53:04 -0500 User-Agent: KMail/1.9.7 References: <681a18e40802111347i3c23c34cve3c1d08b2eaeff0f@mail.gmail.com> In-Reply-To: <681a18e40802111347i3c23c34cve3c1d08b2eaeff0f@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802131153.04293.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 13 Feb 2008 13:28:30 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/5799/Wed Feb 13 10:15:22 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: David Frascone Subject: Re: Small patch to add -a to cp X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2008 18:28:38 -0000 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