and present on several other systems. some ok, some less ok.
from Job Snijders
-.\" $OpenBSD: cp.1,v 1.37 2014/03/19 14:42:44 tedu Exp $
+.\" $OpenBSD: cp.1,v 1.38 2017/06/27 21:43:46 tedu Exp $
.\" $NetBSD: cp.1,v 1.9 1995/07/25 19:36:45 jtc Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993, 1994
.\"
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\"
-.Dd $Mdocdate: March 19 2014 $
+.Dd $Mdocdate: June 27 2017 $
.Dt CP 1
.Os
.Sh NAME
.Nd copy files
.Sh SYNOPSIS
.Nm cp
-.Op Fl fip
+.Op Fl fipv
.Oo
.Fl R
.Op Fl H | L | P
.Oc
.Ar source target
.Nm cp
-.Op Fl fip
+.Op Fl fipv
.Oo
.Fl R
.Op Fl H | L | P
or
.Xr tar 1
instead.
+.It Fl v
+Display the source and destination after each copy.
.El
.Pp
For each destination file that already exists, its contents are
-/* $OpenBSD: cp.c,v 1.44 2016/10/14 10:51:57 schwarze Exp $ */
+/* $OpenBSD: cp.c,v 1.45 2017/06/27 21:43:46 tedu Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
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 };
char *target;
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;
case 'r':
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
break;
case S_IFLNK:
if (copy_link(curr, !fts_dne(curr)))
rval = 1;
+ else if (vflag)
+ (void)fprintf(stdout, "%s -> %s\n",
+ curr->fts_path, to.p_path);
break;
case S_IFDIR:
if (!Rflag && !rflag) {
if (mkdir(to.p_path,
curr->fts_statp->st_mode | S_IRWXU) < 0)
err(1, "%s", to.p_path);
+ else if (vflag)
+ (void)fprintf(stdout, "%s -> %s\n",
+ curr->fts_path, to.p_path);
} else if (!S_ISDIR(to_stat.st_mode))
errc(1, ENOTDIR, "%s", to.p_path);
break;
} else
if (copy_file(curr, fts_dne(curr)))
rval = 1;
+ if (!rval && vflag)
+ (void)fprintf(stdout, "%s -> %s\n",
+ curr->fts_path, to.p_path);
break;
case S_IFIFO:
if (Rflag) {
} else
if (copy_file(curr, fts_dne(curr)))
rval = 1;
+ if (!rval && vflag)
+ (void)fprintf(stdout, "%s -> %s\n",
+ curr->fts_path, to.p_path);
break;
case S_IFSOCK:
warnc(EOPNOTSUPP, "%s", curr->fts_path);
default:
if (copy_file(curr, fts_dne(curr)))
rval = 1;
+ else if (vflag)
+ (void)fprintf(stdout, "%s -> %s\n",
+ curr->fts_path, to.p_path);
break;
}
}
-/* $OpenBSD: utils.c,v 1.39 2015/12/26 18:11:43 guenther Exp $ */
+/* $OpenBSD: utils.c,v 1.40 2017/06/27 21:43:46 tedu Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
usage(void)
{
(void)fprintf(stderr,
- "usage: %s [-fip] [-R [-H | -L | -P]] source target\n", __progname);
+ "usage: %s [-fipv] [-R [-H | -L | -P]] source target\n", __progname);
(void)fprintf(stderr,
- " %s [-fip] [-R [-H | -L | -P]] source ... directory\n",
+ " %s [-fipv] [-R [-H | -L | -P]] source ... directory\n",
__progname);
exit(1);
}
-.\" $OpenBSD: mv.1,v 1.31 2012/06/18 23:41:13 matthew Exp $
+.\" $OpenBSD: mv.1,v 1.32 2017/06/27 21:43:46 tedu Exp $
.\" $NetBSD: mv.1,v 1.8 1995/03/21 09:06:51 cgd Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\"
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
.\"
-.Dd $Mdocdate: June 18 2012 $
+.Dd $Mdocdate: June 27 2017 $
.Dt MV 1
.Os
.Sh NAME
option overrides any previous
.Fl f
options.
+.It Fl v
+Display the source and destination after each move.
.El
.Pp
The
-/* $OpenBSD: mv.c,v 1.44 2016/10/11 16:16:44 millert Exp $ */
+/* $OpenBSD: mv.c,v 1.45 2017/06/27 21:43:46 tedu Exp $ */
/* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */
/*
extern char *__progname;
-int fflg, iflg;
+int fflg, iflg, vflg;
int stdin_ok;
extern int cpmain(int argc, char **argv);
int ch;
char path[PATH_MAX];
- while ((ch = getopt(argc, argv, "if")) != -1)
+ while ((ch = getopt(argc, argv, "ifv")) != -1)
switch (ch) {
case 'i':
fflg = 0;
iflg = 0;
fflg = 1;
break;
+ case 'v':
+ vflg = 1;
+ break;
default:
usage();
}
* message to standard error, and do nothing more with the
* current source file...
*/
- if (!rename(from, to))
+ if (!rename(from, to)) {
+ if (vflg)
+ (void)fprintf(stdout, "%s -> %s\n", from, to);
return (0);
+ }
if (errno != EXDEV) {
warn("rename %s to %s", from, to);
warn("%s: remove", from);
return (1);
}
+
+ if (vflg)
+ (void)fprintf(stdout, "%s -> %s\n", from, to);
+
return (0);
}
_exit(1);
}
+ /*
+ * XXX
+ * The external cpmain(), rmmain() approach (to avoid
+ * fork+exec) hides some of the details on what was moved.
+ * This can be improved upon during a refactor.
+ */
+ if (vflg)
+ (void)fprintf(stdout, "%s -> %s\n", from, to);
+
return (0);
}
void
usage(void)
{
- (void)fprintf(stderr, "usage: %s [-fi] source target\n", __progname);
- (void)fprintf(stderr, " %s [-fi] source ... directory\n",
+ (void)fprintf(stderr, "usage: %s [-fiv] source target\n", __progname);
+ (void)fprintf(stderr, " %s [-fiv] source ... directory\n",
__progname);
exit(1);
}
-.\" $OpenBSD: rm.1,v 1.40 2016/04/15 23:09:57 tedu Exp $
+.\" $OpenBSD: rm.1,v 1.41 2017/06/27 21:43:46 tedu Exp $
.\" $NetBSD: rm.1,v 1.8 1995/07/25 19:37:30 jtc Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\"
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\"
-.Dd $Mdocdate: April 15 2016 $
+.Dd $Mdocdate: June 27 2017 $
.Dt RM 1
.Os
.Sh NAME
.It Fl r
Equivalent to
.Fl R .
+.It Fl v
+Display each file name after it was removed.
.El
.Pp
The
specification.
.Pp
The flags
-.Op Fl dP
+.Op Fl dPv
are extensions to that specification.
.Sh HISTORY
An
-/* $OpenBSD: rm.c,v 1.40 2016/10/14 10:51:57 schwarze Exp $ */
+/* $OpenBSD: rm.c,v 1.41 2017/06/27 21:43:46 tedu Exp $ */
/* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */
/*-
extern char *__progname;
-int dflag, eval, fflag, iflag, Pflag, stdin_ok;
+int dflag, eval, fflag, iflag, Pflag, vflag, stdin_ok;
int check(char *, char *, struct stat *);
void checkdot(char **);
int ch, rflag;
Pflag = rflag = 0;
- while ((ch = getopt(argc, argv, "dfiPRr")) != -1)
+ while ((ch = getopt(argc, argv, "dfiPRrv")) != -1)
switch(ch) {
case 'd':
dflag = 1;
case 'r': /* Compatibility. */
rflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
}
case FTS_DP:
case FTS_DNR:
if (!rmdir(p->fts_accpath) ||
- (fflag && errno == ENOENT))
+ (fflag && errno == ENOENT)) {
+ if (vflag)
+ (void)fprintf(stdout, "%s\n", p->fts_path);
continue;
+ }
break;
case FTS_F:
/* FALLTHROUGH */
default:
if (!unlink(p->fts_accpath) ||
- (fflag && errno == ENOENT))
+ (fflag && errno == ENOENT)) {
+ if (vflag)
+ (void)fprintf(stdout, "%s\n", p->fts_path);
continue;
+ }
}
warn("%s", p->fts_path);
eval = 1;
if (rval && (!fflag || errno != ENOENT)) {
warn("%s", f);
eval = 1;
- }
+ } else if (vflag)
+ (void)fprintf(stdout, "%s\n", f);
}
}
void
usage(void)
{
- (void)fprintf(stderr, "usage: %s [-dfiPRr] file ...\n", __progname);
+ (void)fprintf(stderr, "usage: %s [-dfiPRrv] file ...\n", __progname);
exit(1);
}