about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 057800df6..62426facb 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2593,7 +2593,7 @@ bin_unset(char *name, char **argv, Options ops, int func)
     return returnval;
 }
 
-/* type, whence, which */
+/* type, whence, which, command */
 
 /**/
 int
@@ -2603,6 +2603,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
     Patprog pprog;
     int returnval = 0;
     int printflags = 0;
+    int aliasflags;
     int csh, all, v, wd;
     int informed;
     char *cnam;
@@ -2624,6 +2625,18 @@ bin_whence(char *nam, char **argv, Options ops, int func)
     if (OPT_ISSET(ops,'f'))
 	printflags |= PRINT_WHENCE_FUNCDEF;
 
+    if (func == BIN_COMMAND)
+	if (OPT_ISSET(ops,'V')) {
+	    printflags = aliasflags = PRINT_WHENCE_VERBOSE;
+	    v = 1;
+	} else {
+	    aliasflags = PRINT_LIST;
+	    printflags = PRINT_WHENCE_SIMPLE;
+	    v = 0;
+	}
+    else
+	aliasflags = printflags;
+
     /* With -m option -- treat arguments as a glob patterns */
     if (OPT_ISSET(ops,'m')) {
 	for (; *argv; argv++) {
@@ -2677,7 +2690,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 
 	    /* Look for alias */
 	    if ((hn = aliastab->getnode(aliastab, *argv))) {
-		aliastab->printnode(hn, printflags);
+		aliastab->printnode(hn, aliasflags);
 		if (!all)
 		    continue;
 		informed = 1;