summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-01-12 13:54:29 +0000
committerPeter Stephenson <pws@zsh.org>2017-01-12 13:54:29 +0000
commit33799ae2b00c09445e2e47720bc740ec434416e4 (patch)
tree5ad8280e25112174a72c7924d637fb9fd44db2b3 /Src/exec.c
parentd3cf8816dce8f41bba2436045f38e9884ba04cc0 (diff)
downloadzsh-33799ae2b00c09445e2e47720bc740ec434416e4.tar.gz
zsh-33799ae2b00c09445e2e47720bc740ec434416e4.zip
40335: More care with autoload function path.
If doing "autoload -X", the path present might actually be location of file containing the function with the autoload -X. Add an explicit flag to say it's a directory for autoload.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 7bec7ce48..68c455b18 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5160,7 +5160,8 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
pushheap();
noaliases = (shf->node.flags & PM_UNALIASED);
- if (shf->filename && shf->filename[0] == '/')
+ if (shf->filename && shf->filename[0] == '/' &&
+ (shf->node.flags & PM_LOADDIR))
{
char *spec_path[2];
spec_path[0] = dupstring(shf->filename);
@@ -5203,7 +5204,7 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
shf->funcdef = prog;
else
shf->funcdef = dupeprog(prog, 0);
- shf->node.flags &= ~PM_UNDEFINED;
+ shf->node.flags &= ~(PM_UNDEFINED|PM_LOADDIR);
zsfree(shf->filename);
shf->filename = fname;
} else {
@@ -5227,7 +5228,7 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
shf->funcdef = stripkshdef(prog, shf->node.nam);
else
shf->funcdef = dupeprog(stripkshdef(prog, shf->node.nam), 0);
- shf->node.flags &= ~PM_UNDEFINED;
+ shf->node.flags &= ~(PM_UNDEFINED|PM_LOADDIR);
zsfree(shf->filename);
shf->filename = fname;
}