From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: "whence -v" and function file names
Date: Sat, 25 Apr 2015 12:51:49 -0700 [thread overview]
Message-ID: <150425125149.ZM1489@torch.brasslantern.com> (raw)
In workers/34903 I posted a patch to append the function filename (when
useful) to the "whence -v" output for functions. I temporized:
> I'm undecided about whether the file name should be output using
> nicezputs().
I settled on using quotedzputs(), which will make the filename both human
readable and copy-paste-able.
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 7a43062..ab381cc 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;
}
next reply other threads:[~2015-04-25 19:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-25 19:51 Bart Schaefer [this message]
2015-05-17 20:52 ` Daniel Hahler
2015-05-18 1:44 ` Bart Schaefer
2015-05-18 2:31 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150425125149.ZM1489@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).