sh(1): fix history file write checking

We cannot just compare histsizeval() against 0, since that returns
a string pointer, which is always non-zero (non-null). The logic
in sethistsize() initializes the history size to 100 with values
that are non-number, and an empty string counts as that. Therefore,
the only time we want to not write into history with HISTSIZE val
set is when it's explicitly 0.

MFC after:	2 weeks
This commit is contained in:
Daniel Kolesa 2023-03-20 17:42:59 +01:00 committed by Baptiste Daroussin
parent a6719858a4
commit 3ce64010f8

View file

@ -90,7 +90,7 @@ get_histfile(void)
const char *histfile;
/* don't try to save if the history size is 0 */
if (hist == NULL || histsizeval() == 0)
if (hist == NULL || !strcmp(histsizeval(), "0"))
return (NULL);
histfile = expandstr("${HISTFILE-${HOME-}/.sh_history}");