mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-14 11:41:07 +02:00
18435: unsetting readonly returned status 0
This commit is contained in:
parent
c1bef47364
commit
06b04ca1b2
3 changed files with 13 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
|||
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
|
||||
wrong way round so e.g. `kill -' completed pseudo-signals.
|
||||
|
||||
|
|
|
@ -2580,8 +2580,10 @@ bin_unset(char *name, char **argv, Options ops, int func)
|
|||
zerrnam(name, "%s: invalid element for unset", s, 0);
|
||||
returnval = 1;
|
||||
}
|
||||
} else
|
||||
unsetparam_pm(pm, 0, 1);
|
||||
} else {
|
||||
if (unsetparam_pm(pm, 0, 1))
|
||||
returnval = 1;
|
||||
}
|
||||
if (ss)
|
||||
*ss = '[';
|
||||
}
|
||||
|
|
10
Src/params.c
10
Src/params.c
|
@ -2214,18 +2214,18 @@ unsetparam(char *s)
|
|||
/* Unset a parameter */
|
||||
|
||||
/**/
|
||||
mod_export void
|
||||
mod_export int
|
||||
unsetparam_pm(Param pm, int altflag, int exp)
|
||||
{
|
||||
Param oldpm, altpm;
|
||||
|
||||
if ((pm->flags & PM_READONLY) && pm->level <= locallevel) {
|
||||
zerr("read-only variable: %s", pm->nam, 0);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
|
||||
zerr("%s: restricted", pm->nam, 0);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
pm->unsetfn(pm, exp);
|
||||
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) ||
|
||||
(pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* remove parameter node from table */
|
||||
paramtab->removenode(paramtab, pm->nam);
|
||||
|
@ -2292,6 +2292,8 @@ unsetparam_pm(Param pm, int altflag, int exp)
|
|||
}
|
||||
|
||||
paramtab->freenode((HashNode) pm); /* free parameter node */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Standard function to unset a parameter. This is mostly delegated to *
|
||||
|
|
Loading…
Reference in a new issue