--- busybox-1.19.1/libbb/lineedit.c +++ busybox-1.19.1-hush/libbb/lineedit.c @@ -1425,7 +1425,7 @@ static void save_history(char *str) /* write out temp file and replace hist_file atomically */ new_name = xasprintf("%s.%u.new", state->hist_file, (int) getpid()); - fd = open(state->hist_file, O_WRONLY | O_CREAT | O_TRUNC, 0600); + fd = open(new_name, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd >= 0) { FILE *fp; int i; --- busybox-1.19.1/shell/hush.c +++ busybox-1.19.1-hush/shell/hush.c @@ -7817,20 +7817,24 @@ int hush_main(int argc, char **argv) #if ENABLE_FEATURE_EDITING G.line_input_state = new_line_input_t(FOR_SHELL); -# if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY +# if MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY { const char *hp = get_local_var_value("HISTFILE"); if (!hp) { hp = get_local_var_value("HOME"); - if (hp) { - G.line_input_state->hist_file = concat_path_file(hp, ".hush_history"); - //set_local_var(xasprintf("HISTFILE=%s", ...)); - } + if (hp) + hp = concat_path_file(hp, ".hush_history"); + } else { + hp = xstrdup(hp); } -# if ENABLE_FEATURE_SH_HISTFILESIZE + if (hp) { + G.line_input_state->hist_file = hp; + //set_local_var(xasprintf("HISTFILE=%s", ...)); + } +# if ENABLE_FEATURE_SH_HISTFILESIZE hp = get_local_var_value("HISTFILESIZE"); G.line_input_state->max_history = size_from_HISTFILESIZE(hp); -# endif +# endif } # endif #endif