about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-04-25 12:54:17 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-04-25 12:54:17 -0700
commita9c8b6a076767fa23fd6c779e6c6a95045010f55 (patch)
treeabc51aa37a29898c0f9a1fe5ca71b6004ae513ec
parentfae07f65a3773dd7f8b82ce6169e5ff35766f8f9 (diff)
downloadzsh-a9c8b6a076767fa23fd6c779e6c6a95045010f55.tar.gz
zsh-a9c8b6a076767fa23fd6c779e6c6a95045010f55.tar.xz
zsh-a9c8b6a076767fa23fd6c779e6c6a95045010f55.zip
34966: "whence -v" for a function reports whether the function is autoloaded or its source file when known
-rw-r--r--ChangeLog3
-rw-r--r--Src/hashtable.c14
2 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index dfe43e9fa..da46ea1b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-04-25  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 34966: Src/hashtable.c: "whence -v" for a function reports
+	whether the function is autoloaded or its source file when known
+
 	* 34965: Src/glob.c: consistent use of zalloc/zrealloc/zfree
 
 	* 34961: Completion/Unix/Command/_mkdir: avoid _message because
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 7a430629d..ab381cc6a 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -910,7 +910,7 @@ printshfuncnode(HashNode hn, int printflags)
 {
     Shfunc f = (Shfunc) hn;
     char *t = 0;
- 
+
     if ((printflags & PRINT_NAMEONLY) ||
 	((printflags & PRINT_WHENCE_SIMPLE) &&
 	!(printflags & PRINT_WHENCE_FUNCDEF))) {
@@ -922,8 +922,16 @@ printshfuncnode(HashNode hn, int printflags)
     if ((printflags & (PRINT_WHENCE_VERBOSE|PRINT_WHENCE_WORD)) &&
 	!(printflags & PRINT_WHENCE_FUNCDEF)) {
 	nicezputs(f->node.nam, stdout);
-	printf((printflags & PRINT_WHENCE_WORD) ? ": function\n" :
-	       " is a shell function\n");
+	printf((printflags & PRINT_WHENCE_WORD) ? ": function" :
+	       (f->node.flags & PM_UNDEFINED) ?
+	       " is an autoload shell function" :
+	       " is a shell function");
+	if (f->filename && (printflags & PRINT_WHENCE_VERBOSE) &&
+	    strcmp(f->filename, f->node.nam) != 0) {
+	    printf(" from ");
+	    quotedzputs(f->filename, stdout);
+	}
+	putchar('\n');
 	return;
     }