From 33799ae2b00c09445e2e47720bc740ec434416e4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 12 Jan 2017 13:54:29 +0000 Subject: 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. --- Src/exec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Src/exec.c') 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; } -- cgit v1.2.3-70-g09d2