summaryrefslogtreecommitdiff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-01-18 09:57:55 +0000
committerPeter Stephenson <pws@zsh.org>2017-01-18 09:57:55 +0000
commit4d6097657cb8f19846c5b9e09069f6d4e43882e0 (patch)
tree1e1f1ce89544fca19df8e713237820e3434580cc /Src/builtin.c
parent60a4f6cb67c8872379331aab606985525f978779 (diff)
downloadzsh-4d6097657cb8f19846c5b9e09069f6d4e43882e0.tar.gz
zsh-4d6097657cb8f19846c5b9e09069f6d4e43882e0.zip
40375: autoload with explicit path mustn't trash already loaded function.
Also remove unnecessary dupstring() on already duplicated string when expanding =cmd.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c25
1 files changed, 25 insertions, 0 deletions
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);