Running sh interactively by default leads to history data loss
Description:
Due to an initial false presumption that /etc/profile
was responsible I've filed it here, but it probably belongs into Bash package issue tracker.
/usr/bin/sh
is linked to bash
by default. Merely running sh
interactively can lead to Bash history data loss, even if global defaults are set in /etc/bash.bashrc
. On each interactive sh
run the ~/.bash_history
gets truncated to 500 lines. strace -fe trace=file sh
indicates that no appropriate configuration files in which the history truncation could be disabled are read by sh
.
If /usr/bin/sh
tries to mimic the old sh
with bash
and doesn't load neither /etc/bash.bashrc
nor ~/.bashrc
then it probably shouldn't touch ~/.bash_history
as well, since history is probably considered valid user data that shouldn't get lost so easily. sh
replacement could use ~/.history
if that doesn't interfere with any other shells or not truncate/write history at all. In both cases it could still open ~/.bash_history
read-only and append its data to running history somehow/if Bash does that sort of things.
Additional info:
- package version(s): 2024.04.07-1
Steps to reproduce:
- Produce more than 500 lines of
~/.bash_history
. - Run
sh
. - Observe
~/.bash_history
truncated to 500 lines.