summaryrefslogtreecommitdiffstats
path: root/bin/cp/cp.c
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 /bin/cp/cp.c
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
Diffstat (limited to 'bin/cp/cp.c')
-rw-r--r--bin/cp/cp.c12
1 files changed, 9 insertions, 3 deletions
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);
OpenPOWER on IntegriCloud