/bin/sh (default shell for new users), doesn't save history after reboot. However /bin/csh does preserve history.
$ /bin/csh --help
tcsh 6.21.00 (Astron) 2019-05-08 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec
@Reporter Could you:
- Clarify, is history saved, but then cleared on reboot, or is history never saved? If not, what and how is a reboot a contributing factor?
- Provide minimal steps to reproduce, with expected and actual behaviour described
- Provide uname -a output
While I am in the same /bin/sh shell session, I can go up to view previous commands. However if I close the shell with CTRL+D and open another one (same user, not root), there's no history. After reboot no history either.
The command "history" says "command not found" in sh, but in csh does exist and throws all the commands from previous sessions.
$ uname -a
FreeBSD freebsd 13.0-RELEASE-p3 FreeBSD 13.0-RELEASE-p3 #0: Tue Jun 29 19:46:20 UTC 2021 firstname.lastname@example.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
(In reply to bugzeo from comment #0)
Not all shells have a history file support.
FreeBSD /bin/sh is one that didn't use to have it.
(In reply to Andriy Gapon from comment #3)
> … The sh shell does not use a .history file, …
So is working as intended. sh does not support history on file. If you want to save history, use another shell.
It does in main, since 988b1bb0c54e.
(In reply to Piotr Pawel Stefaniak from comment #6)
That commit reports:
sh: implement persistent history storage
Implement persistent history storage:
the strategy is simple at start: loads the existing .sh_history file
at exit dump it.
. . .
Does the shell in which something like a "shutdown -r now"
is typed cleanly "exit" so that the .sh_history file (or
other file if controlled) is reliably updated? What about
other shell's for possibly other logged-in accounts at the
time of such a reboot?
I'm not so sure that this bugzilla entry should be in the
"closed FIXED" state, even for main [So: 14].