aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-04 12:47:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-04 12:51:38 +0200
commit8d3d0789172ab3f6580d04cd4bbafaef5e108ac7 (patch)
tree797769b90f9afa8974db8943fbd48d023e94115d /libbb
parent9c46a0688576dd8c67d2fc24b68c07402da14fc8 (diff)
downloadbusybox-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 'libbb')
-rw-r--r--libbb/lineedit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index fe0dbc5b8..43d1da35c 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1563,7 +1563,8 @@ void FAST_FUNC save_history(line_input_t *st)
1563{ 1563{
1564 FILE *fp; 1564 FILE *fp;
1565 1565
1566 if (!st || !st->hist_file) 1566 /* bash compat: HISTFILE="" disables history saving */
1567 if (!st || !st->hist_file || !state->hist_file[0])
1567 return; 1568 return;
1568 if (st->cnt_history <= st->cnt_history_in_file) 1569 if (st->cnt_history <= st->cnt_history_in_file)
1569 return; /* no new entries were added */ 1570 return; /* no new entries were added */
@@ -1617,7 +1618,8 @@ static void save_history(char *str)
1617 int fd; 1618 int fd;
1618 int len, len2; 1619 int len, len2;
1619 1620
1620 if (!state->hist_file) 1621 /* bash compat: HISTFILE="" disables history saving */
1622 if (!state->hist_file || !state->hist_file[0])
1621 return; 1623 return;
1622 1624
1623 fd = open(state->hist_file, O_WRONLY | O_CREAT | O_APPEND, 0600); 1625 fd = open(state->hist_file, O_WRONLY | O_CREAT | O_APPEND, 0600);