← Commit list

8d3d07891

Denys Vlasenko
Denys Vlasenko
2025-07-04
SUCCESS Duration: 157s

Subject

shell: empty HISTFILE disables history saving, just as unset one did

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/lineedit.c+4 -2
@@ -1563,7 +1563,8 @@ void FAST_FUNC save_history(line_input_t *st)
{
FILE *fp;
- if (!st || !st->hist_file)
+ /* bash compat: HISTFILE="" disables history saving */
+ if (!st || !st->hist_file || !state->hist_file[0])
return;
if (st->cnt_history <= st->cnt_history_in_file)
return; /* no new entries were added */
@@ -1617,7 +1618,8 @@ static void save_history(char *str)
int fd;
int len, len2;
- if (!state->hist_file)
+ /* bash compat: HISTFILE="" disables history saving */
+ if (!state->hist_file || !state->hist_file[0])
return;
fd = open(state->hist_file, O_WRONLY | O_CREAT | O_APPEND, 0600);
shell/ash.c+1 -1
@@ -14540,7 +14540,7 @@ exitshell(void)
/* HISTFILE: "If unset, the command history is not saved when a shell exits." */
hp = lookupvar("HISTFILE");
line_input_state->hist_file = hp;
- save_history(line_input_state); /* no-op if hist_file is NULL */
+ save_history(line_input_state); /* no-op if hist_file is NULL or "" */
}
#endif
shell/hush.c+1 -1
@@ -2120,7 +2120,7 @@ static void hush_exit(int exitcode)
/* HISTFILE: "If unset, the command history is not saved when a shell exits." */
hp = get_local_var_value("HISTFILE");
G.line_input_state->hist_file = hp;
- save_history(G.line_input_state); /* no-op if hist_file is NULL */
+ save_history(G.line_input_state); /* no-op if hist_file is NULL or "" */
}
#endif