diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/builtin.c | 25 | ||||
-rw-r--r-- | Src/subst.c | 8 |
3 files changed, 35 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 1a4b4c2ce..189399ac5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-01-18 Peter Stephenson <p.stephenson@samsung.com> + + * 40375: Src/builtin.c, Src/subst.c: autoload with explicit path + mustn't trash already loaded function. Also drive-by removal of + duplicated duplication in =cmd expansion. + 2017-01-17 Peter Stephenson <p.stephenson@samsung.com> * unposted: Completion/Zsh/Command/_typeset: autoload ~... also 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); diff --git a/Src/subst.c b/Src/subst.c index 737a0a902..670f3f0c6 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -622,7 +622,7 @@ filesub(char **namptr, int assign) char * equalsubstr(char *str, int assign, int nomatch) { - char *pp, *cnam, *cmdstr, *ret; + char *pp, *cnam, *cmdstr; for (pp = str; !isend2(*pp); pp++) ; @@ -634,10 +634,10 @@ equalsubstr(char *str, int assign, int nomatch) zerr("%s not found", cmdstr); return NULL; } - ret = dupstring(cnam); if (*pp) - ret = dyncat(ret, pp); - return ret; + return dyncat(cnam, pp); + else + return cnam; /* already duplicated */ } /**/ |