diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-12 17:34:13 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-12 17:34:13 +0200 |
commit | 99862cbfad9c36b4f8f4378c3a7a9f077c239f20 (patch) | |
tree | 9fc6aebe4cbe1dce903a208519d7c3d3cb275ce2 | |
parent | 5a0d899ee4b2f05b5b880789b68a2e14698cc966 (diff) | |
download | busybox-w32-99862cbfad9c36b4f8f4378c3a7a9f077c239f20.tar.gz busybox-w32-99862cbfad9c36b4f8f4378c3a7a9f077c239f20.tar.bz2 busybox-w32-99862cbfad9c36b4f8f4378c3a7a9f077c239f20.zip |
hush: optional support for history saving
function old new delta
hush_main 945 995 +50
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | libbb/Config.src | 4 | ||||
-rw-r--r-- | shell/hush.c | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/libbb/Config.src b/libbb/Config.src index 9b01757c6..74dc9c549 100644 --- a/libbb/Config.src +++ b/libbb/Config.src | |||
@@ -78,9 +78,9 @@ config FEATURE_EDITING_HISTORY | |||
78 | config FEATURE_EDITING_SAVEHISTORY | 78 | config FEATURE_EDITING_SAVEHISTORY |
79 | bool "History saving" | 79 | bool "History saving" |
80 | default y | 80 | default y |
81 | depends on ASH && FEATURE_EDITING | 81 | depends on FEATURE_EDITING |
82 | help | 82 | help |
83 | Enable history saving in ash shell. | 83 | Enable history saving in shells. |
84 | 84 | ||
85 | config FEATURE_TAB_COMPLETION | 85 | config FEATURE_TAB_COMPLETION |
86 | bool "Tab completion" | 86 | bool "Tab completion" |
diff --git a/shell/hush.c b/shell/hush.c index ce7467245..752efd0c8 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -146,6 +146,13 @@ | |||
146 | //config: from stdin just like a shell script from a file. | 146 | //config: from stdin just like a shell script from a file. |
147 | //config: No prompt, no PS1/PS2 magic shell variables. | 147 | //config: No prompt, no PS1/PS2 magic shell variables. |
148 | //config: | 148 | //config: |
149 | //config:config HUSH_SAVEHISTORY | ||
150 | //config: bool "Save command history to .hush_history" | ||
151 | //config: default y | ||
152 | //config: depends on HUSH_INTERACTIVE && FEATURE_EDITING_SAVEHISTORY | ||
153 | //config: help | ||
154 | //config: Enable history saving in hush. | ||
155 | //config: | ||
149 | //config:config HUSH_JOB | 156 | //config:config HUSH_JOB |
150 | //config: bool "Job control" | 157 | //config: bool "Job control" |
151 | //config: default y | 158 | //config: default y |
@@ -7415,7 +7422,20 @@ int hush_main(int argc, char **argv) | |||
7415 | 7422 | ||
7416 | #if ENABLE_FEATURE_EDITING | 7423 | #if ENABLE_FEATURE_EDITING |
7417 | G.line_input_state = new_line_input_t(FOR_SHELL); | 7424 | G.line_input_state = new_line_input_t(FOR_SHELL); |
7425 | # if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_HUSH_SAVEHISTORY | ||
7426 | { | ||
7427 | const char *hp = get_local_var_value("HISTFILE"); | ||
7428 | if (!hp) { | ||
7429 | hp = get_local_var_value("HOME"); | ||
7430 | if (hp) { | ||
7431 | G.line_input_state->hist_file = concat_path_file(hp, ".hush_history"); | ||
7432 | //set_local_var(xasprintf("HISTFILE=%s", ...)); | ||
7433 | } | ||
7434 | } | ||
7435 | } | ||
7436 | # endif | ||
7418 | #endif | 7437 | #endif |
7438 | |||
7419 | G.global_argc = argc; | 7439 | G.global_argc = argc; |
7420 | G.global_argv = argv; | 7440 | G.global_argv = argv; |
7421 | /* Initialize some more globals to non-zero values */ | 7441 | /* Initialize some more globals to non-zero values */ |