aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-09-12 17:34:13 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-09-12 17:34:13 +0200
commit99862cbfad9c36b4f8f4378c3a7a9f077c239f20 (patch)
tree9fc6aebe4cbe1dce903a208519d7c3d3cb275ce2
parent5a0d899ee4b2f05b5b880789b68a2e14698cc966 (diff)
downloadbusybox-99862cbfad9c36b4f8f4378c3a7a9f077c239f20.tar.gz
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.src4
-rw-r--r--shell/hush.c20
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
config FEATURE_EDITING_SAVEHISTORY
bool "History saving"
default y
- depends on ASH && FEATURE_EDITING
+ depends on FEATURE_EDITING
help
- Enable history saving in ash shell.
+ Enable history saving in shells.
config FEATURE_TAB_COMPLETION
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 @@
//config: from stdin just like a shell script from a file.
//config: No prompt, no PS1/PS2 magic shell variables.
//config:
+//config:config HUSH_SAVEHISTORY
+//config: bool "Save command history to .hush_history"
+//config: default y
+//config: depends on HUSH_INTERACTIVE && FEATURE_EDITING_SAVEHISTORY
+//config: help
+//config: Enable history saving in hush.
+//config:
//config:config HUSH_JOB
//config: bool "Job control"
//config: default y
@@ -7415,7 +7422,20 @@ 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
+ {
+ 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", ...));
+ }
+ }
+ }
+# endif
#endif
+
G.global_argc = argc;
G.global_argv = argv;
/* Initialize some more globals to non-zero values */