summaryrefslogtreecommitdiffstats
path: root/bin/mv
diff options
context:
space:
mode:
authormharo <mharo@FreeBSD.org>1999-08-29 08:21:16 +0000
committermharo <mharo@FreeBSD.org>1999-08-29 08:21:16 +0000
commit92582195dad1af4e9e5e1be8f7a58503fd3c076a (patch)
tree1191627d2170d3da904eded073d903af3d193a8d /bin/mv
parent5e14615656821e43d8611a79c78c045e4d636190 (diff)
downloadFreeBSD-src-92582195dad1af4e9e5e1be8f7a58503fd3c076a.zip
FreeBSD-src-92582195dad1af4e9e5e1be8f7a58503fd3c076a.tar.gz
add verbose flag
Diffstat (limited to 'bin/mv')
-rw-r--r--bin/mv/mv.16
-rw-r--r--bin/mv/mv.c24
2 files changed, 23 insertions, 7 deletions
diff --git a/bin/mv/mv.1 b/bin/mv/mv.1
index be97d80..efec25d 100644
--- a/bin/mv/mv.1
+++ b/bin/mv/mv.1
@@ -44,9 +44,11 @@
.Sh SYNOPSIS
.Nm mv
.Op Fl f | Fl i
+.Op Fl v
.Ar source target
.Nm mv
.Op Fl f | Fl i
+.Op Fl v
.Ar source ... directory
.Sh DESCRIPTION
In its first form, the
@@ -95,6 +97,10 @@ the move is attempted.
option overrides any previous
.Fl f
options.)
+.It Fl v
+Cause
+.Nm
+to be verbose, showing files after they are moved.
.El
.Pp
It is an error for either the
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 6db4192..5f0f28b 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -60,11 +60,12 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <unistd.h>
#include "pathnames.h"
-int fflg, iflg;
+int fflg, iflg, vflg;
int copy __P((char *, char *));
int do_move __P((char *, char *));
@@ -82,7 +83,7 @@ main(argc, argv)
int ch;
char path[MAXPATHLEN];
- while ((ch = getopt(argc, argv, "fi")) != -1)
+ while ((ch = getopt(argc, argv, "fiv")) != -1)
switch (ch) {
case 'i':
iflg = 1;
@@ -92,6 +93,9 @@ main(argc, argv)
fflg = 1;
iflg = 0;
break;
+ case 'v':
+ vflg = 1;
+ break;
default:
usage();
}
@@ -188,8 +192,11 @@ do_move(from, to)
}
}
}
- if (!rename(from, to))
+ if (!rename(from, to)) {
+ if (vflg)
+ printf("%s -> %s\n", from, to);
return (0);
+ }
if (errno == EXDEV) {
struct statfs sfs;
@@ -299,6 +306,8 @@ err: if (unlink(to))
warn("%s: remove", from);
return (1);
}
+ if (vflg)
+ printf("%s -> %s\n", from, to);
return (0);
}
@@ -309,7 +318,7 @@ copy(from, to)
int pid, status;
if ((pid = fork()) == 0) {
- execl(_PATH_CP, "mv", "-PRp", from, to, NULL);
+ execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", from, to, NULL);
warn("%s", _PATH_CP);
_exit(1);
}
@@ -350,8 +359,9 @@ copy(from, to)
void
usage()
{
+
(void)fprintf(stderr, "%s\n%s\n",
- "usage: mv [-f | -i] source target",
- " mv [-f | -i] source ... directory");
- exit(1);
+ "usage: mv [-f | -i] [-v] source target",
+ " mv [-f | -i] [-v] source ... directory");
+ exit(EX_USAGE);
}
OpenPOWER on IntegriCloud