1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-13 11:21:13 +02:00

18435: unsetting readonly returned status 0

This commit is contained in:
Peter Stephenson 2003-04-04 16:46:25 +00:00
parent c1bef47364
commit 06b04ca1b2
3 changed files with 13 additions and 6 deletions

View file

@ -1,5 +1,8 @@
2003-04-04 Peter Stephenson <pws@csr.com> 2003-04-04 Peter Stephenson <pws@csr.com>
* 18435: Src/builtin.c, Src/params.c: spotted by Oliver: unsetting
a readonly variable returned status 0.
* 18434: Completion/Unix/Type/_signals: -a option was handled the * 18434: Completion/Unix/Type/_signals: -a option was handled the
wrong way round so e.g. `kill -' completed pseudo-signals. wrong way round so e.g. `kill -' completed pseudo-signals.

View file

@ -2580,8 +2580,10 @@ bin_unset(char *name, char **argv, Options ops, int func)
zerrnam(name, "%s: invalid element for unset", s, 0); zerrnam(name, "%s: invalid element for unset", s, 0);
returnval = 1; returnval = 1;
} }
} else } else {
unsetparam_pm(pm, 0, 1); if (unsetparam_pm(pm, 0, 1))
returnval = 1;
}
if (ss) if (ss)
*ss = '['; *ss = '[';
} }

View file

@ -2214,18 +2214,18 @@ unsetparam(char *s)
/* Unset a parameter */ /* Unset a parameter */
/**/ /**/
mod_export void mod_export int
unsetparam_pm(Param pm, int altflag, int exp) unsetparam_pm(Param pm, int altflag, int exp)
{ {
Param oldpm, altpm; Param oldpm, altpm;
if ((pm->flags & PM_READONLY) && pm->level <= locallevel) { if ((pm->flags & PM_READONLY) && pm->level <= locallevel) {
zerr("read-only variable: %s", pm->nam, 0); zerr("read-only variable: %s", pm->nam, 0);
return; return 1;
} }
if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) { if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
zerr("%s: restricted", pm->nam, 0); zerr("%s: restricted", pm->nam, 0);
return; return 1;
} }
pm->unsetfn(pm, exp); pm->unsetfn(pm, exp);
if ((pm->flags & PM_EXPORTED) && pm->env) { if ((pm->flags & PM_EXPORTED) && pm->env) {
@ -2267,7 +2267,7 @@ unsetparam_pm(Param pm, int altflag, int exp)
*/ */
if ((pm->level && locallevel >= pm->level) || if ((pm->level && locallevel >= pm->level) ||
(pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL) (pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL)
return; return 0;
/* remove parameter node from table */ /* remove parameter node from table */
paramtab->removenode(paramtab, pm->nam); paramtab->removenode(paramtab, pm->nam);
@ -2292,6 +2292,8 @@ unsetparam_pm(Param pm, int altflag, int exp)
} }
paramtab->freenode((HashNode) pm); /* free parameter node */ paramtab->freenode((HashNode) pm); /* free parameter node */
return 0;
} }
/* Standard function to unset a parameter. This is mostly delegated to * /* Standard function to unset a parameter. This is mostly delegated to *