Module Name: src
Committed By: kre
Date: Wed Dec 12 07:56:57 UTC 2018
Modified Files:
src/bin/sh: var.c
Log Message:
Fix a botch made in 1.70 (a bit over a week ago) where
var=foo; readonly var=new
now fails.
If var was already set, an attempt to make it readonly, and assign it
a new value at the same time, failed - the readonly flag was set too soon.
Pointed out by Martijn Dekker (thanks).
Also, while here, add a couple of comments.
To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/bin/sh/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/var.c
diff -u src/bin/sh/var.c:1.72 src/bin/sh/var.c:1.73
--- src/bin/sh/var.c:1.72 Tue Dec 4 14:03:30 2018
+++ src/bin/sh/var.c Wed Dec 12 07:56:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.72 2018/12/04 14:03:30 kre Exp $ */
+/* $NetBSD: var.c,v 1.73 2018/12/12 07:56:57 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: var.c,v 1.72 2018/12/04 14:03:30 kre Exp $");
+__RCSID("$NetBSD: var.c,v 1.73 2018/12/12 07:56:57 kre Exp $");
#endif
#endif /* not lint */
@@ -879,13 +879,17 @@ exportcmd(int argc, char **argv)
if (nflg)
vp->flags &= ~flag;
else if (flag&VEXPORT && vp->flags&VNOEXPORT) {
+ /* note we go ahead and do any assignment */
sh_warnx("%.*s: not available for export",
len, name);
res = 1;
} else {
- vp->flags |= flag;
if (flag == VNOEXPORT)
vp->flags &= ~VEXPORT;
+
+ /* if not NULL will be done in setvar below */
+ if (p == NULL)
+ vp->flags |= flag;
}
if (p == NULL)
continue;