From 34f70c5dc08bbecd20fbb8a1797851103fbad45e Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Sat, 28 Jan 2017 19:33:27 +0000
Subject: 40440: Add $functions_source hash to zsh/parameter.
This allows you to find out where a function was loaded from.
---
Test/V06parameter.ztst | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
(limited to 'Test/V06parameter.ztst')
diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst
index c7df35dce..c2a2a4da5 100644
--- a/Test/V06parameter.ztst
+++ b/Test/V06parameter.ztst
@@ -1,15 +1,15 @@
%test
print 'print In sourced file
- print $LINENO + $functrace + $funcsourcetrace
+ print $LINENO + $functrace + ${funcsourcetrace/#$PWD/CURDIR}
' >sourcedfile
print -r -- 'print Started functrace.zsh
module_path=(./Modules)
- print $LINENO + $functrace + $funcsourcetrace
+ print $LINENO + $functrace + ${funcsourcetrace/#$PWD/CURDIR}
:
fn() {
print Inside function $0
- print $LINENO + $functrace + $funcsourcetrace
+ print $LINENO + $functrace + ${funcsourcetrace/#$PWD/CURDIR}
}
:
fn
@@ -17,7 +17,7 @@
fpath=(. $fpath)
:
echo '\''print Inside $0
- print $LINENO + $functrace + $funcsourcetrace
+ print $LINENO + $functrace + ${funcsourcetrace/#$PWD/CURDIR}
'\'' >autofn
:
autoload autofn
@@ -32,9 +32,9 @@
>Inside function fn
>2 + ./functrace.zsh:10 + ./functrace.zsh:5
>Inside autofn
->2 + ./functrace.zsh:20 + ./autofn:0
+>2 + ./functrace.zsh:20 + CURDIR/autofn:0
>Inside autofn
->2 + ./functrace.zsh:21 + ./autofn:0
+>2 + ./functrace.zsh:21 + CURDIR/autofn:0
>In sourced file
>2 + ./functrace.zsh:22 + ./sourcedfile:0
@@ -66,6 +66,19 @@
>./rocky3.zsh:13 (eval):2
>./rocky3.zsh:14 ./rocky3.zsh:14
+ (
+ fpath=($PWD)
+ print "print I have been autoloaded" >myfunc
+ autoload $PWD/myfunc
+ print ${functions_source[myfunc]/#$PWD/CURDIR}
+ myfunc
+ print ${functions_source[myfunc]/#$PWD/CURDIR}
+ )
+0: $functions_source
+>CURDIR/myfunc
+>I have been autoloaded
+>CURDIR/myfunc
+
%clean
- rm -f autofn functrace.zsh rocky3.zsh sourcedfile
+ rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc
--
cgit 1.4.1