diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-31 13:16:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-31 13:16:52 +0200 |
commit | 2c4de5b045a79db73052d5b865474a00c9a87e99 (patch) | |
tree | 12a5c2c7a0685ab1674e6b07959688a3470359fd /shell | |
parent | a439fa93f64e6eb34f0633d00d203b4267d58521 (diff) | |
download | busybox-w32-2c4de5b045a79db73052d5b865474a00c9a87e99.tar.gz busybox-w32-2c4de5b045a79db73052d5b865474a00c9a87e99.tar.bz2 busybox-w32-2c4de5b045a79db73052d5b865474a00c9a87e99.zip |
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.src | 10 | ||||
-rw-r--r-- | shell/ash.c | 9 | ||||
-rw-r--r-- | shell/hush.c | 4 |
3 files changed, 20 insertions, 3 deletions
diff --git a/shell/Config.src b/shell/Config.src index e96c21620..b31e62dda 100644 --- a/shell/Config.src +++ b/shell/Config.src | |||
@@ -136,4 +136,14 @@ config FEATURE_SH_NOFORK | |||
136 | This feature is relatively new. Use with care. Report bugs | 136 | This feature is relatively new. Use with care. Report bugs |
137 | to project mailing list. | 137 | to project mailing list. |
138 | 138 | ||
139 | config FEATURE_SH_HISTFILESIZE | ||
140 | bool "Use $HISTFILESIZE" | ||
141 | default y | ||
142 | depends on HUSH || ASH | ||
143 | help | ||
144 | This option makes busybox shells to use $HISTFILESIZE variable | ||
145 | to set shell history size. Note that its max value is capped | ||
146 | by "History size" setting in library tuning section. | ||
147 | |||
148 | |||
139 | endmenu | 149 | endmenu |
diff --git a/shell/ash.c b/shell/ash.c index 1520c5ae5..11ba9774a 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13143,10 +13143,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13143 | #if ENABLE_FEATURE_EDITING_SAVEHISTORY | 13143 | #if ENABLE_FEATURE_EDITING_SAVEHISTORY |
13144 | if (iflag) { | 13144 | if (iflag) { |
13145 | const char *hp = lookupvar("HISTFILE"); | 13145 | const char *hp = lookupvar("HISTFILE"); |
13146 | 13146 | if (!hp) { | |
13147 | if (hp == NULL) { | ||
13148 | hp = lookupvar("HOME"); | 13147 | hp = lookupvar("HOME"); |
13149 | if (hp != NULL) { | 13148 | if (hp) { |
13150 | char *defhp = concat_path_file(hp, ".ash_history"); | 13149 | char *defhp = concat_path_file(hp, ".ash_history"); |
13151 | setvar("HISTFILE", defhp, 0); | 13150 | setvar("HISTFILE", defhp, 0); |
13152 | free(defhp); | 13151 | free(defhp); |
@@ -13195,6 +13194,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13195 | const char *hp = lookupvar("HISTFILE"); | 13194 | const char *hp = lookupvar("HISTFILE"); |
13196 | if (hp) | 13195 | if (hp) |
13197 | line_input_state->hist_file = hp; | 13196 | line_input_state->hist_file = hp; |
13197 | # if ENABLE_FEATURE_SH_HISTFILESIZE | ||
13198 | hp = lookupvar("HISTFILESIZE"); | ||
13199 | line_input_state->max_history = size_from_HISTFILESIZE(hp); | ||
13200 | # endif | ||
13198 | } | 13201 | } |
13199 | #endif | 13202 | #endif |
13200 | state4: /* XXX ??? - why isn't this before the "if" statement */ | 13203 | state4: /* XXX ??? - why isn't this before the "if" statement */ |
diff --git a/shell/hush.c b/shell/hush.c index e698e6c52..d3e957c2f 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -7614,6 +7614,10 @@ int hush_main(int argc, char **argv) | |||
7614 | //set_local_var(xasprintf("HISTFILE=%s", ...)); | 7614 | //set_local_var(xasprintf("HISTFILE=%s", ...)); |
7615 | } | 7615 | } |
7616 | } | 7616 | } |
7617 | # if ENABLE_FEATURE_SH_HISTFILESIZE | ||
7618 | hp = get_local_var_value("HISTFILESIZE"); | ||
7619 | G.line_input_state->max_history = size_from_HISTFILESIZE(hp); | ||
7620 | # endif | ||
7617 | } | 7621 | } |
7618 | # endif | 7622 | # endif |
7619 | #endif | 7623 | #endif |