ash: an unset dynamic variable should not be dynamic
authorRon Yorston <rmy@pobox.com>
Mon, 15 Apr 2019 09:49:35 +0000 (10:49 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 16 Apr 2019 16:29:52 +0000 (18:29 +0200)
Commit b28d4c346 (ash: [VAR] Move unsetvar functionality into setvareq)
dropped the code that caused dynamic variables to lose their special
properties when unset.  Add it back again.

function                                             old     new   delta
setvareq                                             346     360     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0)               Total: 14 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index 34d5d6d68fa064b8cec543a9bada49dfa2e6ecc5..255d57e6249c6afbb99c4a3e579e576de18f502e 100644 (file)
@@ -2364,6 +2364,10 @@ setvareq(char *s, int flags)
                }
 
                flags |= vp->flags & ~(VTEXTFIXED|VSTACK|VNOSAVE|VUNSET);
+#if ENABLE_ASH_RANDOM_SUPPORT
+               if (flags & VUNSET)
+                       flags &= ~VDYNAMIC;
+#endif
        } else {
                /* variable s is not found */
                if (flags & VNOSET)