diff options
-rw-r--r-- | shell/hush.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/shell/hush.c b/shell/hush.c index da10a09a8..92c79b8b6 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2423,35 +2423,33 @@ static void set_vars_and_save_old(char **strings) | |||
2423 | char *eq; | 2423 | char *eq; |
2424 | 2424 | ||
2425 | eq = strchr(*s, '='); | 2425 | eq = strchr(*s, '='); |
2426 | if (eq) { | 2426 | if (HUSH_DEBUG && !eq) |
2427 | var_pp = get_ptr_to_local_var(*s, eq - *s); | ||
2428 | if (var_pp) { | ||
2429 | var_p = *var_pp; | ||
2430 | if (var_p->flg_read_only) { | ||
2431 | char **p; | ||
2432 | bb_error_msg("%s: readonly variable", *s); | ||
2433 | /* | ||
2434 | * "VAR=V BLTIN" unsets VARs after BLTIN completes. | ||
2435 | * If VAR is readonly, leaving it in the list | ||
2436 | * after asssignment error (msg above) | ||
2437 | * causes doubled error message later, on unset. | ||
2438 | */ | ||
2439 | debug_printf_env("removing/freeing '%s' element\n", *s); | ||
2440 | free(*s); | ||
2441 | p = s; | ||
2442 | do { *p = p[1]; p++; } while (*p); | ||
2443 | goto next; | ||
2444 | } | ||
2445 | /* below, set_local_var() with nest level will | ||
2446 | * "shadow" (remove) this variable from | ||
2447 | * global linked list. | ||
2448 | */ | ||
2449 | } | ||
2450 | debug_printf_env("%s: env override '%s'/%u\n", __func__, *s, G.var_nest_level); | ||
2451 | set_local_var(*s, (G.var_nest_level << SETFLAG_VARLVL_SHIFT) | SETFLAG_EXPORT); | ||
2452 | } else if (HUSH_DEBUG) { | ||
2453 | bb_error_msg_and_die("BUG in varexp4"); | 2427 | bb_error_msg_and_die("BUG in varexp4"); |
2428 | var_pp = get_ptr_to_local_var(*s, eq - *s); | ||
2429 | if (var_pp) { | ||
2430 | var_p = *var_pp; | ||
2431 | if (var_p->flg_read_only) { | ||
2432 | char **p; | ||
2433 | bb_error_msg("%s: readonly variable", *s); | ||
2434 | /* | ||
2435 | * "VAR=V BLTIN" unsets VARs after BLTIN completes. | ||
2436 | * If VAR is readonly, leaving it in the list | ||
2437 | * after asssignment error (msg above) | ||
2438 | * causes doubled error message later, on unset. | ||
2439 | */ | ||
2440 | debug_printf_env("removing/freeing '%s' element\n", *s); | ||
2441 | free(*s); | ||
2442 | p = s; | ||
2443 | do { *p = p[1]; p++; } while (*p); | ||
2444 | goto next; | ||
2445 | } | ||
2446 | /* below, set_local_var() with nest level will | ||
2447 | * "shadow" (remove) this variable from | ||
2448 | * global linked list. | ||
2449 | */ | ||
2454 | } | 2450 | } |
2451 | debug_printf_env("%s: env override '%s'/%u\n", __func__, *s, G.var_nest_level); | ||
2452 | set_local_var(*s, (G.var_nest_level << SETFLAG_VARLVL_SHIFT) | SETFLAG_EXPORT); | ||
2455 | s++; | 2453 | s++; |
2456 | next: ; | 2454 | next: ; |
2457 | } | 2455 | } |