aboutsummaryrefslogtreecommitdiff
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
parentf645e1573c5521c87b972400f9b4abc3636983d4 (diff)
downloadbusybox-w32-cf5110978ba25002ec5cb46aaae2472eb66001ac.tar.gz
busybox-w32-cf5110978ba25002ec5cb46aaae2472eb66001ac.tar.bz2
busybox-w32-cf5110978ba25002ec5cb46aaae2472eb66001ac.zip
hush: fix readonly2.tests failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c11
-rw-r--r--shell/hush_test/hush-vars/readonly2.right1
-rwxr-xr-xshell/hush_test/hush-vars/readonly2.tests1
3 files changed, 13 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)
2287 if (var_pp) { 2287 if (var_pp) {
2288 var_p = *var_pp; 2288 var_p = *var_pp;
2289 if (var_p->flg_read_only) { 2289 if (var_p->flg_read_only) {
2290 char **p;
2290 bb_error_msg("%s: readonly variable", *s); 2291 bb_error_msg("%s: readonly variable", *s);
2292 /*
2293 * "VAR=V BLTIN" unsets VARs after BLTIN completes.
2294 * If VAR is readonly, leaving it in the list
2295 * after asssignment error (msg above)
2296 * causes doubled error message later, on unset.
2297 */
2298 debug_printf_env("removing/freeing '%s' element\n", *s);
2299 free(*s);
2300 p = s;
2301 do { *p = p[1]; p++; } while (*p);
2291 goto next; 2302 goto next;
2292 } 2303 }
2293 /* Remove variable from global linked list */ 2304 /* Remove variable from global linked list */
diff --git a/shell/hush_test/hush-vars/readonly2.right b/shell/hush_test/hush-vars/readonly2.right
index 5b02ddfe8..38551d4ad 100644
--- a/shell/hush_test/hush-vars/readonly2.right
+++ b/shell/hush_test/hush-vars/readonly2.right
@@ -1,4 +1,5 @@
1hush: a=Z: readonly variable 1hush: a=Z: readonly variable
2Visible:42 2Visible:42
3
3hush: a=Z: readonly variable 4hush: a=Z: readonly variable
4Visible:42 5Visible:42
diff --git a/shell/hush_test/hush-vars/readonly2.tests b/shell/hush_test/hush-vars/readonly2.tests
index d9d178edd..b758d9602 100755
--- a/shell/hush_test/hush-vars/readonly2.tests
+++ b/shell/hush_test/hush-vars/readonly2.tests
@@ -3,4 +3,5 @@ readonly a=A
3 3
4# external commands and builtins should behave the same: 4# external commands and builtins should behave the same:
5(exit 42); a=Z echo "Visible:$?" 5(exit 42); a=Z echo "Visible:$?"
6echo
6(exit 42); a=Z env echo "Visible:$?" 7(exit 42); a=Z env echo "Visible:$?"