Subject: ln.diff take 2
To: None <tech-userlevel@netbsd.org>
From: Jason R. Fink <jrf@adresearch.com>
List: tech-userlevel
Date: 12/20/2002 13:57:55
--SUOF0GtieIMvvwua
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here is the "new -v option" with ln command.

All I did was setup the if/else that was requested,
it appears to work but I would like a few tests so I
can move on (no pun intended) to mv and rm.

	j

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

--SUOF0GtieIMvvwua
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/20 18:49:33
@@ -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
+Cause
+.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/20 18:49:33
@@ -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 [-fhns] file1 file2\n\t%s [-fhnsv] file ... directory\n",
 	    getprogname(), getprogname());
 	exit(1);
 	/* NOTREACHED */

--SUOF0GtieIMvvwua--