--- old/usr/src/cmd/rm/rm.c	2014-04-29 16:44:00.177546599 +0100
+++ new/usr/src/cmd/rm/rm.c	2014-04-29 16:44:00.182553258 +0100
@@ -20,6 +20,10 @@
  */
 
 /*
+ * Copyright 2014 Andrew Stormont.
+ */
+
+/*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
@@ -28,7 +32,7 @@
 /*	All Rights Reserved   */
 
 /*
- * rm [-fiRr] file ...
+ * rm [-fiRrv] file ...
  */
 
 #include <sys/param.h>
@@ -74,8 +78,13 @@
 static int confirm(FILE *, const char *, ...);
 static void memerror(void);
 static int checkdir(struct dlist *, struct dlist *);
-static int errcnt;
-static boolean_t silent, interactive, recursive, ontty;
+static int errcnt = 0;
+
+static boolean_t force = B_FALSE;
+static boolean_t interactive = B_FALSE;
+static boolean_t recursive = B_FALSE;
+static boolean_t ontty = B_FALSE;
+static boolean_t verbose = B_FALSE;
 
 static char *pathbuf;
 static size_t pathbuflen = MAXPATHLEN;
@@ -95,24 +104,23 @@
 #endif
 	(void) textdomain(TEXT_DOMAIN);
 
-	while ((c = getopt(argc, argv, "frRi")) != EOF)
+	while ((c = getopt(argc, argv, "frRiv")) != EOF)
 		switch (c) {
 		case 'f':
-			silent = B_TRUE;
-#ifdef XPG4
+			force = B_TRUE;
 			interactive = B_FALSE;
-#endif
 			break;
 		case 'i':
 			interactive = B_TRUE;
-#ifdef XPG4
-			silent = B_FALSE;
-#endif
+			force = B_FALSE;
 			break;
 		case 'r':
 		case 'R':
 			recursive = B_TRUE;
 			break;
+		case 'v':
+			verbose = B_TRUE;
+			break;
 		case '?':
 			errflg = 1;
 			break;
@@ -132,8 +140,9 @@
 	argc -= optind;
 	argv = &argv[optind];
 
-	if ((argc < 1 && !silent) || errflg) {
-		(void) fprintf(stderr, gettext("usage: rm [-fiRr] file ...\n"));
+	if ((argc < 1 && !force) || errflg) {
+		(void) fprintf(stderr,
+		    gettext("usage: rm [-fiRrv] file ...\n"));
 		exit(2);
 	}
 
@@ -328,11 +337,9 @@
 	pushfilename(entry);
 
 	if (fstatat(caller->fd, entry, &temp, AT_SYMLINK_NOFOLLOW) != 0) {
-		if (!silent) {
-			(void) fprintf(stderr, "rm: %s: %s\n", pathbuf,
-			    strerror(errno));
-			errcnt++;
-		}
+		(void) fprintf(stderr, "rm: %s: %s\n", pathbuf,
+		    strerror(errno));
+		errcnt++;
 		return (0);
 	}
 
@@ -375,13 +382,13 @@
 		frame.flags = 0;
 		flag = AT_REMOVEDIR;
 
-#ifdef XPG4
+#ifndef	SUS
 		/*
 		 * XCU4 and POSIX.2: If not interactive, check to see whether
 		 * or not directory is readable or writable and if not,
 		 * prompt user for response.
 		 */
-		if (ontty && !interactive && !silent &&
+		if (ontty && !interactive && !force &&
 		    faccessat(caller->fd, entry, W_OK|X_OK, AT_EACCESS) != 0 &&
 		    !confirm(stderr,
 		    gettext("rm: examine files in directory %s (%s/%s)? "),
@@ -389,6 +396,7 @@
 			return (0);
 		}
 #endif
+
 		if (opendirat(caller->fd, entry, &frame) == -1) {
 			err = errno;
 
@@ -425,8 +433,12 @@
 				}
 			}
 			/* If it's empty we may still be able to rm it */
-			if (unlinkat(caller->fd, entry, flag) == 0)
+			if (unlinkat(caller->fd, entry, flag) == 0) {
+				if (verbose)
+					(void) printf(gettext("removed "
+					    "directory: `%s'\n"), pathbuf);
 				return (0);
+			}
 			if (interactive)
 				err = errno;
 			(void) fprintf(stderr,
@@ -498,9 +510,9 @@
 		    pathbuf, yesstr, nostr)) {
 			return (0);
 		}
-	} else if (!silent && flag == 0) {
+	} else if (!force && flag == 0) {
 		/*
-		 * If not silent, and stdin is a terminal, and there's
+		 * If not force, and stdin is a terminal, and there's
 		 * no write access, and the file isn't a symbolic link,
 		 * ask for permission.  If flag is set, then we know it's
 		 * a directory so we skip this test as it was done above.
@@ -523,7 +535,13 @@
 		}
 	}
 
-	if (unlinkat(caller->fd, entry, flag) != 0) {
+	if (unlinkat(caller->fd, entry, flag) == 0) {
+		if (verbose)
+			(void) printf(S_ISDIR(temp.st_mode) ?
+			    gettext("removed directory: `%s'\n") :
+			    gettext("removed `%s'\n"), pathbuf);
+		return (0);
+	} else {
 		err = errno;
 		if (err == ENOENT)
 			return (0);
@@ -541,16 +559,11 @@
 				    gettext("rm: Unable to remove directory %s:"
 				    " %s\n"), pathbuf, strerror(err));
 			}
+#ifndef	SUS
 		} else {
-#ifndef XPG4
-			if (!silent || interactive) {
-#endif
-
-				(void) fprintf(stderr,
-				    gettext("rm: %s not removed: %s\n"),
-				    pathbuf, strerror(err));
-#ifndef XPG4
-			}
+			(void) fprintf(stderr,
+			    gettext("rm: %s not removed: %s\n"),
+			    pathbuf, strerror(err));
 #endif
 		}
 		errcnt++;
