hush: randomconfig fixes

This commit is contained in:
Denis Vlasenko 2009-04-05 08:43:57 +00:00
parent cc4c693ec5
commit d85a5df159

View File

@ -2359,12 +2359,13 @@ static void re_execute_shell(const char *s)
if (!cur->flg_export || cur->flg_read_only) if (!cur->flg_export || cur->flg_read_only)
cnt += 2; cnt += 2;
} }
//TODO: need to free these strings in parent! G.argv_for_re_execing = pp = xzalloc(sizeof(argv[0]) * cnt);
G.argv_for_re_execing = pp = xmalloc(sizeof(argv[0]) * cnt);
*pp++ = (char *) applet_name; *pp++ = (char *) applet_name;
*pp++ = xasprintf("-$%u", G.root_pid); *pp++ = xasprintf("-$%u", G.root_pid);
*pp++ = xasprintf("-?%u", G.last_return_code); *pp++ = xasprintf("-?%u", G.last_return_code);
#if ENABLE_HUSH_LOOPS
*pp++ = xasprintf("-D%u", G.depth_of_loop); *pp++ = xasprintf("-D%u", G.depth_of_loop);
#endif
for (cur = G.top_var; cur; cur = cur->next) { for (cur = G.top_var; cur; cur = cur->next) {
if (cur->varstr == hush_version_str) if (cur->varstr == hush_version_str)
continue; continue;
@ -2381,7 +2382,7 @@ static void re_execute_shell(const char *s)
pp2 = G.global_argv; pp2 = G.global_argv;
while (*pp2) while (*pp2)
*pp++ = *pp2++; *pp++ = *pp2++;
*pp = NULL; /* *pp = NULL; - is already there */
//TODO: pass traps and functions //TODO: pass traps and functions
debug_printf_exec("re_execute_shell pid:%d cmd:'%s'\n", getpid(), s); debug_printf_exec("re_execute_shell pid:%d cmd:'%s'\n", getpid(), s);
@ -2398,7 +2399,9 @@ static void clean_up_after_re_execute(void)
/* Must match re_execute_shell's allocations */ /* Must match re_execute_shell's allocations */
free(pp[1]); free(pp[1]);
free(pp[2]); free(pp[2]);
#if ENABLE_HUSH_LOOPS
free(pp[3]); free(pp[3]);
#endif
free(pp); free(pp);
G.argv_for_re_execing = NULL; G.argv_for_re_execing = NULL;
} }
@ -4281,6 +4284,7 @@ static int handle_dollar(struct parse_context *ctx,
o_addchr(dest, SPECIAL_VAR_SYMBOL); o_addchr(dest, SPECIAL_VAR_SYMBOL);
break; break;
} }
#if (ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK)
case '(': { case '(': {
# if !BB_MMU # if !BB_MMU
int pos; int pos;
@ -4331,6 +4335,7 @@ static int handle_dollar(struct parse_context *ctx,
# endif # endif
break; break;
} }
#endif
case '_': case '_':
ch = i_getch(input); ch = i_getch(input);
#if !BB_MMU #if !BB_MMU
@ -5075,9 +5080,11 @@ int hush_main(int argc, char **argv)
case '?': case '?':
G.last_return_code = xatoi_u(optarg); G.last_return_code = xatoi_u(optarg);
break; break;
#if ENABLE_HUSH_LOOPS
case 'D': case 'D':
G.depth_of_loop = xatoi_u(optarg); G.depth_of_loop = xatoi_u(optarg);
break; break;
#endif
case 'R': case 'R':
case 'V': case 'V':
set_local_var(xstrdup(optarg), 0, opt == 'R'); set_local_var(xstrdup(optarg), 0, opt == 'R');