diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/shell/hush.c b/shell/hush.c index e4138adf7..7a34f59ae 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1541,6 +1541,10 @@ static sighandler_t pick_sighandler(unsigned sig) | |||
1541 | static void hush_exit(int exitcode) NORETURN; | 1541 | static void hush_exit(int exitcode) NORETURN; |
1542 | static void hush_exit(int exitcode) | 1542 | static void hush_exit(int exitcode) |
1543 | { | 1543 | { |
1544 | #if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT | ||
1545 | save_history(G.line_input_state); | ||
1546 | #endif | ||
1547 | |||
1544 | fflush_all(); | 1548 | fflush_all(); |
1545 | if (G.exiting <= 0 && G.traps && G.traps[0] && G.traps[0][0]) { | 1549 | if (G.exiting <= 0 && G.traps && G.traps[0] && G.traps[0][0]) { |
1546 | char *argv[3]; | 1550 | char *argv[3]; |
@@ -7817,22 +7821,6 @@ int hush_main(int argc, char **argv) | |||
7817 | 7821 | ||
7818 | #if ENABLE_FEATURE_EDITING | 7822 | #if ENABLE_FEATURE_EDITING |
7819 | G.line_input_state = new_line_input_t(FOR_SHELL); | 7823 | G.line_input_state = new_line_input_t(FOR_SHELL); |
7820 | # if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY | ||
7821 | { | ||
7822 | const char *hp = get_local_var_value("HISTFILE"); | ||
7823 | if (!hp) { | ||
7824 | hp = get_local_var_value("HOME"); | ||
7825 | if (hp) { | ||
7826 | G.line_input_state->hist_file = concat_path_file(hp, ".hush_history"); | ||
7827 | //set_local_var(xasprintf("HISTFILE=%s", ...)); | ||
7828 | } | ||
7829 | } | ||
7830 | # if ENABLE_FEATURE_SH_HISTFILESIZE | ||
7831 | hp = get_local_var_value("HISTFILESIZE"); | ||
7832 | G.line_input_state->max_history = size_from_HISTFILESIZE(hp); | ||
7833 | # endif | ||
7834 | } | ||
7835 | # endif | ||
7836 | #endif | 7824 | #endif |
7837 | 7825 | ||
7838 | /* Initialize some more globals to non-zero values */ | 7826 | /* Initialize some more globals to non-zero values */ |
@@ -8104,6 +8092,27 @@ int hush_main(int argc, char **argv) | |||
8104 | /* -1 is special - makes xfuncs longjmp, not exit | 8092 | /* -1 is special - makes xfuncs longjmp, not exit |
8105 | * (we reset die_sleep = 0 whereever we [v]fork) */ | 8093 | * (we reset die_sleep = 0 whereever we [v]fork) */ |
8106 | enable_restore_tty_pgrp_on_exit(); /* sets die_sleep = -1 */ | 8094 | enable_restore_tty_pgrp_on_exit(); /* sets die_sleep = -1 */ |
8095 | |||
8096 | # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 | ||
8097 | { | ||
8098 | const char *hp = get_local_var_value("HISTFILE"); | ||
8099 | if (!hp) { | ||
8100 | hp = get_local_var_value("HOME"); | ||
8101 | if (hp) | ||
8102 | hp = concat_path_file(hp, ".hush_history"); | ||
8103 | } else { | ||
8104 | hp = xstrdup(hp); | ||
8105 | } | ||
8106 | if (hp) { | ||
8107 | G.line_input_state->hist_file = hp; | ||
8108 | //set_local_var(xasprintf("HISTFILE=%s", ...)); | ||
8109 | } | ||
8110 | # if ENABLE_FEATURE_SH_HISTFILESIZE | ||
8111 | hp = get_local_var_value("HISTFILESIZE"); | ||
8112 | G.line_input_state->max_history = size_from_HISTFILESIZE(hp); | ||
8113 | # endif | ||
8114 | } | ||
8115 | # endif | ||
8107 | } else { | 8116 | } else { |
8108 | install_special_sighandlers(); | 8117 | install_special_sighandlers(); |
8109 | } | 8118 | } |