From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] Make 'whence -v autoloaded-function' shows the defining filename.
Date: Thu, 4 Aug 2016 15:53:27 +0000 [thread overview]
Message-ID: <1470326007-3112-1-git-send-email-danielsh@tarsus.local2> (raw)
This may also fix a problem whereby the %x prompt escape evaluated to
a function name rather than a filename, since %x is also backed by
scriptfilename.
---
Src/exec.c | 3 ++-
Test/C04funcdef.ztst | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Src/exec.c b/Src/exec.c
index 515406f..ea9214d 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4915,7 +4915,8 @@ execautofn_basic(Estate state, UNUSED(int do_exec))
oldscriptname = scriptname;
oldscriptfilename = scriptfilename;
- scriptname = scriptfilename = dupstring(shf->node.nam);
+ scriptname = dupstring(shf->node.nam);
+ scriptfilename = dupstring(shf->filename);
execode(shf->funcdef, 1, 0, "loadautofunc");
scriptname = oldscriptname;
scriptfilename = oldscriptfilename;
diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst
index 496577f..9f15e04 100644
--- a/Test/C04funcdef.ztst
+++ b/Test/C04funcdef.ztst
@@ -321,6 +321,16 @@
> print oops was successfully autoloaded
>}
+ (
+ fpath=(.)
+ printf '%s\n' 'oops(){}' 'ninjas-earring(){}' 'oops "$@"' >oops
+ autoload oops
+ oops
+ whence -v oops
+ )
+0:whence -v of zsh-style autoload
+>oops is a shell function from ./oops
+
%clean
rm -f file.in file.out
reply other threads:[~2016-08-04 15:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1470326007-3112-1-git-send-email-danielsh@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--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).