summaryrefslogtreecommitdiffhomepage
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 15:58:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 15:58:02 +0200
commitcf5110978ba25002ec5cb46aaae2472eb66001ac (patch)
tree466f85060d6ce52d8fc9f4b4d4551754a166295b /shell/hush.c
parentf645e1573c5521c87b972400f9b4abc3636983d4 (diff)
hush: fix readonly2.tests failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 55e581e16..f6da826d3 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2287,7 +2287,18 @@ static struct variable *set_vars_and_save_old(char **strings)
if (var_pp) {
var_p = *var_pp;
if (var_p->flg_read_only) {
+ char **p;
bb_error_msg("%s: readonly variable", *s);
+ /*
+ * "VAR=V BLTIN" unsets VARs after BLTIN completes.
+ * If VAR is readonly, leaving it in the list
+ * after asssignment error (msg above)
+ * causes doubled error message later, on unset.
+ */
+ debug_printf_env("removing/freeing '%s' element\n", *s);
+ free(*s);
+ p = s;
+ do { *p = p[1]; p++; } while (*p);
goto next;
}
/* Remove variable from global linked list */