git: 0edfc2a92c80 - stable/13 - sh(1): fix history file write checking

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Fri, 19 May 2023 08:10:29 UTC
The branch stable/13 has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=0edfc2a92c80650c2b9ea8d8572752d0a1e6e8eb

commit 0edfc2a92c80650c2b9ea8d8572752d0a1e6e8eb
Author:     Daniel Kolesa <q66@chimera-linux.org>
AuthorDate: 2023-03-20 16:42:59 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-05-19 08:07:37 +0000

    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
    
    (cherry picked from commit 3ce64010f8ce3accc64eff312f31dc0d3c0fc9d1)
---
 bin/sh/histedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index b9af20e6e9ab..dc4bff469d3f 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -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}");