summaryrefslogtreecommitdiff
path: root/bin/ksh/var.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-11-21 23:12:05 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-11-21 23:12:05 +0000
commitf9ff957831f96886025ddf86479739a2fc55a95f (patch)
tree282bd51f1ef13797c0d8750b2948f3774d650df6 /bin/ksh/var.c
parenta43ea2cdf28fb18264ce09f7a79b8f8595b78133 (diff)
Bug fixes from pdksh-5.2.14-patches.1:
o set -x dumps core (shf.c); o "typeset -r foo=bar" fails saying foo is readonly (var.c).
Diffstat (limited to 'bin/ksh/var.c')
-rw-r--r--bin/ksh/var.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/ksh/var.c b/bin/ksh/var.c
index 71ddc4f9d2e..4ce18214597 100644
--- a/bin/ksh/var.c
+++ b/bin/ksh/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.10 1999/06/15 01:18:36 millert Exp $ */
+/* $OpenBSD: var.c,v 1.11 2000/11/21 23:12:04 millert Exp $ */
#include "sh.h"
#include "ksh_time.h"
@@ -357,7 +357,9 @@ setstr(vq, s, error_ok)
const char *s;
int error_ok;
{
- if (vq->flag & RDONLY) {
+ int no_ro_check = error_ok & 0x4;
+ error_ok &= ~0x4;
+ if ((vq->flag & RDONLY) && !no_ro_check) {
warningf(TRUE, "%s: is read only", vq->name);
if (!error_ok)
errorf(null);
@@ -719,13 +721,13 @@ typeset(var, set, clr, field, base)
if (val != NULL) {
if (vp->flag&INTEGER) {
/* do not zero base before assignment */
- setstr(vp, val, KSH_UNWIND_ERROR);
+ setstr(vp, val, KSH_UNWIND_ERROR | 0x4);
/* Done after assignment to override default */
if (base > 0)
vp->type = base;
} else
/* setstr can't fail (readonly check already done) */
- setstr(vp, val, KSH_RETURN_ERROR);
+ setstr(vp, val, KSH_RETURN_ERROR | 0x4);
}
/* only x[0] is ever exported, so use vpbase */