1 The following commit has been modified to fit BusyBox 1.19.2 instead of BusyBox git
2 --Dennis Groenen <tj.groenen@gmail.com> - 2011-09-10
4 From 4840ae8a06298e987374fa3cc6d7e4969fd19344 Mon Sep 17 00:00:00 2001
5 From: Denys Vlasenko <vda.linux@googlemail.com>
6 Date: Sun, 4 Sep 2011 15:28:03 +0200
7 Subject: [PATCH 1/3] lineedit: fix atomic replace of history file; hush: fix
10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
13 --- a/libbb/lineedit.c
14 +++ b/libbb/lineedit.c
15 @@ -1475,7 +1475,7 @@ static void remember_in_history(char *st
16 /* i <= state->max_history */
17 state->cur_history = i;
18 state->cnt_history = i;
19 -# if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
20 +# if ENABLE_FEATURE_EDITING_SAVEHISTORY
21 if ((state->flags & SAVE_HISTORY) && state->hist_file)
26 @@ -13194,7 +13194,7 @@ int ash_main(int argc UNUSED_PARAM, char
29 if (sflag || minusc == NULL) {
30 -#if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
31 +#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
33 const char *hp = lookupvar("HISTFILE");
37 @@ -7816,27 +7816,7 @@ int hush_main(int argc, char **argv)
40 #if ENABLE_FEATURE_EDITING
41 - G.line_input_state = new_line_input_t(FOR_SHELL);
42 -# if MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY
44 - const char *hp = get_local_var_value("HISTFILE");
46 - hp = get_local_var_value("HOME");
48 - hp = concat_path_file(hp, ".hush_history");
53 - G.line_input_state->hist_file = hp;
54 - //set_local_var(xasprintf("HISTFILE=%s", ...));
56 -# if ENABLE_FEATURE_SH_HISTFILESIZE
57 - hp = get_local_var_value("HISTFILESIZE");
58 - G.line_input_state->max_history = size_from_HISTFILESIZE(hp);
62 + G.line_input_state = new_line_input_t(FOR_SHELL & ~SAVE_HISTORY);
65 /* Initialize some more globals to non-zero values */
66 @@ -8108,6 +8088,28 @@ int hush_main(int argc, char **argv)
67 /* -1 is special - makes xfuncs longjmp, not exit
68 * (we reset die_sleep = 0 whereever we [v]fork) */
69 enable_restore_tty_pgrp_on_exit(); /* sets die_sleep = -1 */
71 +# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0
73 + const char *hp = get_local_var_value("HISTFILE");
75 + hp = get_local_var_value("HOME");
77 + hp = concat_path_file(hp, ".hush_history");
82 + G.line_input_state->hist_file = hp;
83 + G.line_input_state->flags |= SAVE_HISTORY;
84 + //set_local_var(xasprintf("HISTFILE=%s", ...));
86 +# if ENABLE_FEATURE_SH_HISTFILESIZE
87 + hp = get_local_var_value("HISTFILESIZE");
88 + G.line_input_state->max_history = size_from_HISTFILESIZE(hp);
93 install_special_sighandlers();