summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2011-03-31 13:16:52 +0200
committerDenys Vlasenko2011-03-31 13:16:52 +0200
commit2c4de5b045a79db73052d5b865474a00c9a87e99 (patch)
tree12a5c2c7a0685ab1674e6b07959688a3470359fd /shell
parenta439fa93f64e6eb34f0633d00d203b4267d58521 (diff)
downloadbusybox-2c4de5b045a79db73052d5b865474a00c9a87e99.zip
busybox-2c4de5b045a79db73052d5b865474a00c9a87e99.tar.gz
ash,hush: optional support for $HISTFILESIZE.
Based on patch from Alexey Fomenko (ext-alexey.fomenko AT nokia.com) function old new delta size_from_HISTFILESIZE - 44 +44 hush_main 998 1025 +27 ash_main 1348 1374 +26 read_line_input 3361 3372 +11 new_line_input_t 17 24 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/Config.src10
-rw-r--r--shell/ash.c9
-rw-r--r--shell/hush.c4
3 files changed, 20 insertions, 3 deletions
diff --git a/shell/Config.src b/shell/Config.src
index e96c216..b31e62d 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -136,4 +136,14 @@ config FEATURE_SH_NOFORK
This feature is relatively new. Use with care. Report bugs
to project mailing list.
+config FEATURE_SH_HISTFILESIZE
+ bool "Use $HISTFILESIZE"
+ default y
+ depends on HUSH || ASH
+ help
+ This option makes busybox shells to use $HISTFILESIZE variable
+ to set shell history size. Note that its max value is capped
+ by "History size" setting in library tuning section.
+
+
endmenu
diff --git a/shell/ash.c b/shell/ash.c
index 1520c5a..11ba977 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13143,10 +13143,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
const char *hp = lookupvar("HISTFILE");
-
- if (hp == NULL) {
+ if (!hp) {
hp = lookupvar("HOME");
- if (hp != NULL) {
+ if (hp) {
char *defhp = concat_path_file(hp, ".ash_history");
setvar("HISTFILE", defhp, 0);
free(defhp);
@@ -13195,6 +13194,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
const char *hp = lookupvar("HISTFILE");
if (hp)
line_input_state->hist_file = hp;
+# if ENABLE_FEATURE_SH_HISTFILESIZE
+ hp = lookupvar("HISTFILESIZE");
+ line_input_state->max_history = size_from_HISTFILESIZE(hp);
+# endif
}
#endif
state4: /* XXX ??? - why isn't this before the "if" statement */
diff --git a/shell/hush.c b/shell/hush.c
index e698e6c..d3e957c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7614,6 +7614,10 @@ int hush_main(int argc, char **argv)
//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