mirror of
https://github.com/sheumann/hush.git
synced 2024-08-26 12:29:04 +00:00
hush: randomconfig fixes
This commit is contained in:
parent
cc4c693ec5
commit
d85a5df159
13
shell/hush.c
13
shell/hush.c
@ -2359,12 +2359,13 @@ static void re_execute_shell(const char *s)
|
||||
if (!cur->flg_export || cur->flg_read_only)
|
||||
cnt += 2;
|
||||
}
|
||||
//TODO: need to free these strings in parent!
|
||||
G.argv_for_re_execing = pp = xmalloc(sizeof(argv[0]) * cnt);
|
||||
G.argv_for_re_execing = pp = xzalloc(sizeof(argv[0]) * cnt);
|
||||
*pp++ = (char *) applet_name;
|
||||
*pp++ = xasprintf("-$%u", G.root_pid);
|
||||
*pp++ = xasprintf("-?%u", G.last_return_code);
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
*pp++ = xasprintf("-D%u", G.depth_of_loop);
|
||||
#endif
|
||||
for (cur = G.top_var; cur; cur = cur->next) {
|
||||
if (cur->varstr == hush_version_str)
|
||||
continue;
|
||||
@ -2381,7 +2382,7 @@ static void re_execute_shell(const char *s)
|
||||
pp2 = G.global_argv;
|
||||
while (*pp2)
|
||||
*pp++ = *pp2++;
|
||||
*pp = NULL;
|
||||
/* *pp = NULL; - is already there */
|
||||
//TODO: pass traps and functions
|
||||
|
||||
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 */
|
||||
free(pp[1]);
|
||||
free(pp[2]);
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
free(pp[3]);
|
||||
#endif
|
||||
free(pp);
|
||||
G.argv_for_re_execing = NULL;
|
||||
}
|
||||
@ -4281,6 +4284,7 @@ static int handle_dollar(struct parse_context *ctx,
|
||||
o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
break;
|
||||
}
|
||||
#if (ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK)
|
||||
case '(': {
|
||||
# if !BB_MMU
|
||||
int pos;
|
||||
@ -4331,6 +4335,7 @@ static int handle_dollar(struct parse_context *ctx,
|
||||
# endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case '_':
|
||||
ch = i_getch(input);
|
||||
#if !BB_MMU
|
||||
@ -5075,9 +5080,11 @@ int hush_main(int argc, char **argv)
|
||||
case '?':
|
||||
G.last_return_code = xatoi_u(optarg);
|
||||
break;
|
||||
#if ENABLE_HUSH_LOOPS
|
||||
case 'D':
|
||||
G.depth_of_loop = xatoi_u(optarg);
|
||||
break;
|
||||
#endif
|
||||
case 'R':
|
||||
case 'V':
|
||||
set_local_var(xstrdup(optarg), 0, opt == 'R');
|
||||
|
Loading…
Reference in New Issue
Block a user