From 4d6097657cb8f19846c5b9e09069f6d4e43882e0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 18 Jan 2017 09:57:55 +0000 Subject: 40375: autoload with explicit path mustn't trash already loaded function. Also remove unnecessary dupstring() on already duplicated string when expanding =cmd. --- Src/builtin.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index b1b6e2e30..7a04a79a7 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3369,6 +3369,31 @@ bin_functions(char *name, char **argv, Options ops, int func) removetrapnode(signum); } + if (**argv == '/') { + char *base = strrchr(*argv, '/') + 1; + if (*base && + (shf = (Shfunc) shfunctab->getnode(shfunctab, base))) { + char *dir; + /* turn on/off the given flags */ + shf->node.flags = + (shf->node.flags | (on & ~PM_UNDEFINED)) & ~off; + if (shf->node.flags & PM_UNDEFINED) { + /* update path if not yet loaded */ + if (base == *argv + 1) + dir = "/"; + else { + dir = *argv; + base[-1] = '\0'; + } + dircache_set(&shf->filename, NULL); + dircache_set(&shf->filename, dir); + } + if (check_autoload(shf, shf->node.nam, ops, func)) + returnval = 1; + continue; + } + } + /* Add a new undefined (autoloaded) function to the * * hash table with the corresponding flags set. */ shf = (Shfunc) zshcalloc(sizeof *shf); -- cgit 1.4.1