Subject: ln.diff Correction, mv.diff
To: None <tech-userlevel@netbsd.org>
From: Jason R. Fink <jrf@adresearch.com>
List: tech-userlevel
Date: 12/21/2002 09:51:47
--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hullo,

Here is a corrected ln.diff and a new mv.diff.

	j
-- 
Jay Fink http://pyxis.homeunix.net/
NetBSD Developer http://www.netbsd.org/
Senior SysAdmin/Programmer, Ipsos http://www.ipsos.com/

--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ln.diff"

Index: ln.1
===================================================================
RCS file: /cvsroot/src/bin/ln/ln.1,v
retrieving revision 1.16
diff -u -r1.16 ln.1
--- ln.1	2002/09/25 15:18:39	1.16
+++ ln.1	2002/12/21 14:48:51
@@ -44,11 +44,11 @@
 .Nd make links
 .Sh SYNOPSIS
 .Nm
-.Op Fl fhns
+.Op Fl fhnsv
 .Ar source_file
 .Op Ar target_file
 .Nm ""
-.Op Fl fhns
+.Op Fl fhnsv
 .Ar source_file ... target_dir
 .Sh DESCRIPTION
 The
@@ -87,6 +87,10 @@
 implementations.
 .It Fl s
 Create a symbolic link.
+.It Fl v
+Causes
+.Nm
+to be verbose, showing files as they are processed.
 .El
 .Pp
 By default
@@ -146,6 +150,10 @@
 .Nm
 utility conforms to
 .St -p1003.2-92 .
+.Pp
+The flag
+.Op Fl v
+is an extension to the specification.
 .Sh HISTORY
 A
 .Nm
Index: ln.c
===================================================================
RCS file: /cvsroot/src/bin/ln/ln.c,v
retrieving revision 1.20
diff -u -r1.20 ln.c
--- ln.c	2002/10/30 22:52:10	1.20
+++ ln.c	2002/12/21 14:48:51
@@ -60,8 +60,10 @@
 int	fflag;				/* Unlink existing files. */
 int	hflag;				/* Check new name for symlink first. */
 int	sflag;				/* Symbolic, not hard, link. */
+int	vflag;				/* Verbose output */
 					/* System link call. */
 int (*linkf)(const char *, const char *);
+char	linkch;
 
 int	linkit(char *, char *, int);
 void	usage(void);
@@ -75,7 +77,7 @@
 	char *sourcedir;
 
 	setprogname(argv[0]);
-	while ((ch = getopt(argc, argv, "fhns")) != -1)
+	while ((ch = getopt(argc, argv, "fhnsv")) != -1)
 		switch (ch) {
 		case 'f':
 			fflag = 1;
@@ -87,6 +89,9 @@
 		case 's':
 			sflag = 1;
 			break;
+		case 'v':
+			vflag = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -95,7 +100,13 @@
 	argv += optind;
 	argc -= optind;
 
-	linkf = sflag ? symlink : link;
+	if (sflag) {
+		linkf  = symlink;
+		linkch = '-';
+	} else {
+		linkf  = link;
+		linkch = '=';
+	}
 
 	switch(argc) {
 	case 0:
@@ -162,6 +173,8 @@
 		warn("%s", source);
 		return (1);
 	}
+	if (vflag)
+		(void)printf("%s %c> %s\n", source, linkch, target);
 
 	return (0);
 }
@@ -171,7 +184,7 @@
 {
 
 	(void)fprintf(stderr,
-	    "Usage:\t%s [-fhns] file1 file2\n\t%s [-fhns] file ... directory\n",
+	    "Usage:\t%s [-fhnsv] file1 file2\n\t%s [-fhnsv] file ... directory\n",
 	    getprogname(), getprogname());
 	exit(1);
 	/* NOTREACHED */

--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mv.diff"

Index: mv.1
===================================================================
RCS file: /cvsroot/src/bin/mv/mv.1,v
retrieving revision 1.18
diff -u -r1.18 mv.1
--- mv.1	2002/02/08 01:21:58	1.18
+++ mv.1	2002/12/21 14:49:58
@@ -44,10 +44,10 @@
 .Nd move files
 .Sh SYNOPSIS
 .Nm
-.Op Fl fi
+.Op Fl fiv
 .Ar source target
 .Nm ""
-.Op Fl fi
+.Op Fl fiv
 .Ar source ... directory
 .Sh DESCRIPTION
 In its first form, the
@@ -83,6 +83,10 @@
 overwrite an existing file.
 If the response from the standard input begins with the character ``y'',
 the move is attempted.
+.It Fl v
+Causes
+.Nm 
+to be verbose, showing files as they are processed.
 .El
 The last of any
 .Fl f
Index: mv.c
===================================================================
RCS file: /cvsroot/src/bin/mv/mv.c,v
retrieving revision 1.27
diff -u -r1.27 mv.c
--- mv.c	2001/09/16 21:53:55	1.27
+++ mv.c	2002/12/21 14:49:58
@@ -68,7 +68,7 @@
 
 #include "pathnames.h"
 
-int fflg, iflg;
+int fflg, iflg, vflg;
 int stdin_ok;
 
 int copy(char *, char *);
@@ -88,7 +88,7 @@
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "if")) != -1)
+	while ((ch = getopt(argc, argv, "ifv")) != -1)
 		switch (ch) {
 		case 'i':
 			fflg = 0;
@@ -98,6 +98,9 @@
 			iflg = 0;
 			fflg = 1;
 			break;
+		case 'v':
+			vflg = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -210,8 +213,11 @@
 	 *	message to standard error, and do nothing more with the
 	 *	current source file...
 	 */
-	if (!rename(from, to))
+	if (!rename(from, to)) {
+		if (vflg)
+			printf("%s -> %s\n", from, to);
 		return (0);
+	}
 
 	if (errno != EXDEV) {
 		warn("rename %s to %s", from, to);
@@ -313,6 +319,10 @@
 		warn("%s: remove", from);
 		return (1);
 	}
+
+	if (vflg)
+		printf("%s -> %s\n", from, to);
+
 	return (0);
 }
 
@@ -322,7 +332,7 @@
 	int pid, status;
 
 	if ((pid = vfork()) == 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);
 	}
@@ -363,8 +373,8 @@
 void
 usage(void)
 {
-	(void)fprintf(stderr, "usage: %s [-fi] source target\n"
-	    "       %s [-fi] source ... directory\n", getprogname(),
+	(void)fprintf(stderr, "usage: %s [-fiv] source target\n"
+	    "       %s [-fiv] source ... directory\n", getprogname(),
 	    getprogname());
 	exit(1);
 	/* NOTREACHED */

--liOOAslEiF7prFVr--