Subject: bin/16834: bring -v option to cp(1) from freebsd
To: None <gnats-bugs@gnats.netbsd.org>
From: None <keramida@FreeBSD.org>
List: netbsd-bugs
Date: 05/15/2002 12:19:34
>Number: 16834
>Category: bin
>Synopsis: bring -v option to cp(1) from freebsd
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed May 15 12:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Giorgos Keramidas
>Release:
>Organization:
>Environment:
>Description:
While looking for differences in the cp(1) command, between FreeBSD
and NetBSD, I noticed NetBSD cp doesn't have a -v option. This patch
adds the option to basesrc/bin/cp/cp.c and updates the manpage.
>How-To-Repeat:
>Fix:
Index: cp.1
===================================================================
RCS file: /home/netbsd/basesrc/bin/cp/cp.1,v
retrieving revision 1.19
diff -u -r1.19 cp.1
--- cp.1 8 Feb 2002 01:21:55 -0000 1.19
+++ cp.1 15 May 2002 19:14:45 -0000
@@ -49,7 +49,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i
-.Op Fl p
+.Op Fl pv
.Ar source_file target_file
.Nm cp
.Oo
@@ -57,7 +57,7 @@
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i
-.Op Fl p
+.Op Fl pv
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
@@ -139,6 +139,10 @@
and either the user ID or group ID cannot be preserved, neither
the set user ID or set group ID bits are preserved in the copy's
permissions.
+.It Fl v
+Cause
+.Nm
+to be verbose, showing files as they are copied.
.El
.Pp
For each destination file that already exists, its contents are
@@ -201,6 +205,10 @@
This implementation supports that option, however, its use is strongly
discouraged, as it does not correctly copy special files, symbolic links
or fifo's.
+.Pp
+The
+.Fl v
+option is non-standard and its use in scripts is not recommended.
.Sh SEE ALSO
.Xr mv 1 ,
.Xr rcp 1 ,
Index: cp.c
===================================================================
RCS file: /home/netbsd/basesrc/bin/cp/cp.c,v
retrieving revision 1.31
diff -u -r1.31 cp.c
--- cp.c 13 Sep 2001 09:53:59 -0000 1.31
+++ cp.c 15 May 2002 18:55:38 -0000
@@ -88,7 +88,7 @@
PATH_T to = { to.p_path, "" };
uid_t myuid;
-int Rflag, fflag, iflag, pflag, rflag;
+int Rflag, fflag, iflag, pflag, rflag, vflag;
mode_t myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -108,7 +108,7 @@
(void)setlocale(LC_ALL, "");
Hflag = Lflag = Pflag = Rflag = 0;
- while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
+ while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -139,6 +139,9 @@
case 'r':
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
case '?':
default:
usage();
@@ -452,6 +455,8 @@
rval = 1;
break;
}
+ if (vflag && rval != 0)
+ (void)printf("%s -> %s\n", curr->fts_path, to.p_path);
}
if (errno)
err(1, "fts_read");
>Release-Note:
>Audit-Trail:
>Unformatted: