summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormharo <mharo@FreeBSD.org>1999-08-26 02:44:56 +0000
committermharo <mharo@FreeBSD.org>1999-08-26 02:44:56 +0000
commit5f9fd788f5751f044f8cf0fb01e67fb1e88a1acc (patch)
treeffb954a44343badb205e655c73d0df289677ed8b
parentb658a57c222af53cd4c00082ea592a9d9a5921f7 (diff)
downloadFreeBSD-src-5f9fd788f5751f044f8cf0fb01e67fb1e88a1acc.zip
FreeBSD-src-5f9fd788f5751f044f8cf0fb01e67fb1e88a1acc.tar.gz
Add a verbose mode to show what files are being copied.
Idea taken from obrien. Reviewed by: obrien
-rw-r--r--bin/cp/cp.18
-rw-r--r--bin/cp/cp.c12
-rw-r--r--bin/cp/extern.h4
-rw-r--r--bin/cp/utils.c9
4 files changed, 24 insertions, 9 deletions
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
index b9d047e..c3ae299 100644
--- a/bin/cp/cp.1
+++ b/bin/cp/cp.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
-.\" $Id: cp.1,v 1.11 1998/10/13 08:52:29 jkoshy Exp $
+.\" $Id: cp.1,v 1.12 1999/05/08 10:19:25 kris Exp $
.\"
.Dd April 18, 1994
.Dt CP 1
@@ -49,6 +49,7 @@
.Oc
.Op Fl f | i
.Op Fl p
+.Op Fl v
.Ar source_file target_file
.Nm cp
.Oo
@@ -57,6 +58,7 @@
.Oc
.Op Fl f | i
.Op Fl p
+.Op Fl v
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
@@ -145,6 +147,10 @@ If the source file has both its set user ID and set group ID bits on,
and either the user ID or group ID cannot be preserved, neither
the set user ID nor 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
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 524d2e5..77587c9 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -45,7 +45,7 @@ static char const copyright[] =
static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
#endif
static const char rcsid[] =
- "$Id: cp.c,v 1.19 1999/05/08 10:19:27 kris Exp $";
+ "$Id: cp.c,v 1.20 1999/07/10 05:46:44 kris Exp $";
#endif /* not lint */
/*
@@ -69,6 +69,7 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <fts.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -82,7 +83,7 @@ static const char rcsid[] =
PATH_T to = { to.p_path, "", "" };
uid_t myuid;
-int Rflag, iflag, pflag, rflag, fflag;
+int Rflag, iflag, pflag, rflag, fflag, vflag;
int myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -101,7 +102,7 @@ main(argc, argv)
char *target;
Hflag = Lflag = Pflag = 0;
- while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
+ while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -132,6 +133,9 @@ main(argc, argv)
case 'r':
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
break;
@@ -374,6 +378,8 @@ copy(argv, type, fts_options)
if (mkdir(to.p_path,
curr->fts_statp->st_mode | S_IRWXU) < 0)
err(1, "%s", to.p_path);
+ if (vflag)
+ printf("%s -> %s\n", curr->fts_path, to.p_path);
} else if (!S_ISDIR(to_stat.st_mode)) {
errno = ENOTDIR;
err(1, "%s", to.p_path);
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index d6f6c29..c53970c 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/1/94
- * $Id$
+ * $Id: extern.h,v 1.7 1997/02/22 14:01:33 peter Exp $
*/
typedef struct {
@@ -42,7 +42,7 @@ typedef struct {
extern PATH_T to;
extern uid_t myuid;
-extern int iflag, pflag, fflag, myumask;
+extern int iflag, pflag, fflag, vflag, myumask;
#include <sys/cdefs.h>
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 162a446..837a3da 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
#endif
static const char rcsid[] =
- "$Id: utils.c,v 1.22 1999/04/25 21:13:32 imp Exp $";
+ "$Id: utils.c,v 1.23 1999/05/08 10:19:29 kris Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -118,6 +118,9 @@ copy_file(entp, dne)
rval = 0;
+ if (vflag)
+ printf("%s -> %s\n",entp->fts_path, to.p_path);
+
/*
* Mmap and write if less than 8M (the limit is so we don't totally
* trash memory on big files. This is really a minor hack, but it
@@ -321,7 +324,7 @@ void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
-"usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target",
-" cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory");
+"usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] [-v] src target",
+" cp [-R [-H | -L | -P]] [-f | -i] [-p] [-v] src1 ... srcN directory");
exit(1);
}
OpenPOWER on IntegriCloud