diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-04 12:47:11 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-04 12:51:38 +0200 |
| commit | 8d3d0789172ab3f6580d04cd4bbafaef5e108ac7 (patch) | |
| tree | 797769b90f9afa8974db8943fbd48d023e94115d /shell | |
| parent | 9c46a0688576dd8c67d2fc24b68c07402da14fc8 (diff) | |
| download | busybox-w32-8d3d0789172ab3f6580d04cd4bbafaef5e108ac7.tar.gz busybox-w32-8d3d0789172ab3f6580d04cd4bbafaef5e108ac7.tar.bz2 busybox-w32-8d3d0789172ab3f6580d04cd4bbafaef5e108ac7.zip | |
shell: empty HISTFILE disables history saving, just as unset one did
The rationale here is that unsetting HISTFILE in /etc/profile
does not "stick": if it's unset, the default one is set later
(after /etc/profile is executed) by the shell.
But setting (and exporting, so it is inherited by all
(grand)child shells) an empty one works.
function old new delta
save_history 296 316 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 2 | ||||
| -rw-r--r-- | shell/hush.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 18344767a..1a85eec71 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -14540,7 +14540,7 @@ exitshell(void) | |||
| 14540 | /* HISTFILE: "If unset, the command history is not saved when a shell exits." */ | 14540 | /* HISTFILE: "If unset, the command history is not saved when a shell exits." */ |
| 14541 | hp = lookupvar("HISTFILE"); | 14541 | hp = lookupvar("HISTFILE"); |
| 14542 | line_input_state->hist_file = hp; | 14542 | line_input_state->hist_file = hp; |
| 14543 | save_history(line_input_state); /* no-op if hist_file is NULL */ | 14543 | save_history(line_input_state); /* no-op if hist_file is NULL or "" */ |
| 14544 | } | 14544 | } |
| 14545 | #endif | 14545 | #endif |
| 14546 | 14546 | ||
diff --git a/shell/hush.c b/shell/hush.c index 68aca53a3..0b2bc01f5 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -2120,7 +2120,7 @@ static void hush_exit(int exitcode) | |||
| 2120 | /* HISTFILE: "If unset, the command history is not saved when a shell exits." */ | 2120 | /* HISTFILE: "If unset, the command history is not saved when a shell exits." */ |
| 2121 | hp = get_local_var_value("HISTFILE"); | 2121 | hp = get_local_var_value("HISTFILE"); |
| 2122 | G.line_input_state->hist_file = hp; | 2122 | G.line_input_state->hist_file = hp; |
| 2123 | save_history(G.line_input_state); /* no-op if hist_file is NULL */ | 2123 | save_history(G.line_input_state); /* no-op if hist_file is NULL or "" */ |
| 2124 | } | 2124 | } |
| 2125 | #endif | 2125 | #endif |
| 2126 | 2126 | ||
