git: 3ce64010f8ce - main - sh(1): fix history file write checking
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Mar 2023 16:57:09 UTC
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3ce64010f8ce3accc64eff312f31dc0d3c0fc9d1 commit 3ce64010f8ce3accc64eff312f31dc0d3c0fc9d1 Author: Daniel Kolesa <q66@chimera-linux.org> AuthorDate: 2023-03-20 16:42:59 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2023-03-20 16:56:56 +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 --- 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 0eb8c6c1784f..db3b8bcfc1da 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}");