Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Fix a botch made in 1.70 (a bit over a week ago) where



details:   https://anonhg.NetBSD.org/src/rev/ce08019bda7f
branches:  trunk
changeset: 446596:ce08019bda7f
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Dec 12 07:56:57 2018 +0000

description:
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.

diffstat:

 bin/sh/var.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 9df21eab4a4b -r ce08019bda7f bin/sh/var.c
--- a/bin/sh/var.c      Wed Dec 12 07:07:30 2018 +0000
+++ b/bin/sh/var.c      Wed Dec 12 07:56:57 2018 +0000
@@ -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 @@
                        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;



Home | Main Index | Thread Index | Old Index