diff options
Diffstat (limited to 'Src/params.c')
-rw-r--r-- | Src/params.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Src/params.c b/Src/params.c index 396c97c3a..26b3f3133 100644 --- a/Src/params.c +++ b/Src/params.c @@ -2342,6 +2342,7 @@ mod_export int unsetparam_pm(Param pm, int altflag, int exp) { Param oldpm, altpm; + char *altremove; if ((pm->flags & PM_READONLY) && pm->level <= locallevel) { zerr("read-only variable: %s", pm->nam, 0); @@ -2351,13 +2352,20 @@ unsetparam_pm(Param pm, int altflag, int exp) zerr("%s: restricted", pm->nam, 0); return 1; } - pm->gsu.s->unsetfn(pm, exp); + + if (pm->ename && !altflag) + altremove = ztrdup(pm->ename); + else + altremove = NULL; + + if (!(pm->flags & PM_UNSET)) + pm->gsu.s->unsetfn(pm, exp); if (pm->env) delenv(pm); /* remove it under its alternate name if necessary */ - if (pm->ename && !altflag) { - altpm = (Param) paramtab->getnode(paramtab, pm->ename); + if (altremove) { + altpm = (Param) paramtab->getnode(paramtab, altremove); /* tied parameters are at the same local level as each other */ oldpm = NULL; while (altpm && altpm->level > pm->level) { @@ -2373,6 +2381,8 @@ unsetparam_pm(Param pm, int altflag, int exp) } unsetparam_pm(altpm, 1, exp); } + + zsfree(altremove); } /* @@ -2438,6 +2448,8 @@ stdunsetfn(Param pm, UNUSED(int exp)) pm->u.str = NULL; break; } + if (!(pm->flags & PM_SPECIAL)) + pm->flags &= ~PM_TIED; pm->flags |= PM_UNSET; } @@ -2815,6 +2827,7 @@ tiedarrunsetfn(Param pm, UNUSED(int exp)) zsfree(pm->ename); pm->ename = NULL; pm->flags &= ~PM_TIED; + pm->flags |= PM_UNSET; } /**/ |