You are not logged in.
I have the following entries in my .bashrc to try to ensure that I don't accidentally overwrite the history file by closing one of multiple long-lived shells:
```
shopt -s histappend
export PROMPT_COMMAND='history -n; history -a' # This is supposed to allow interleaving histories, but I'm not sure if that is the case. Maybe replace -n with -r?
HISTSIZE=100000
HISTFILESIZE=100000
HISTCONTROL='ignoreboth:erasedups'
```
While this can improved on, at least it works reasonably well.
However, I noticed that /usr/bin/sh is a symlink to bash, and if I
```
$ sh
$ exit
$ cat ~/.bash_history | wc -l
```
, the history is truncated to 500 lines.
It appears that with sh, HISTSIZE=500, HISTFILE=$HOME/.bash_history.
I don't suppose I can just delete /usr/bin/sh? ![]()
Or rather, does bash invoked via the sh symlink respect some configuration file other than .bashrc?
Does it take cli arguments I should alias it with?
Last edited by mbw (2023-11-12 08:44:34)
Offline
https://man.archlinux.org/man/core/bash … INVOCATION
If bash is invoked with the name sh
I don't suppose I can just delete /usr/bin/sh?
Oh, you /can/.
Do you /want/?
Probably not ![]()
This is all only relevant for interactive shells, though and /bin/sh is typically for scripts, nobody runs that as interactive shell b/c you don't get all your fancy interactive shell config.
Offline
You could set an alias that starts sh without HISTFILE:
alias sh='HISTFILE= sh'alternatively, in .bashrc you could set a nonstandard HISTFILE:
HISTFILE=~/.bash_history_customand sh would keep using .bash_history anyway since it doesn't load the bashrc at all
or you could try setting HISTSIZE globally in /etc/environment or something, not sure if that would work if it's just about truncate behavior. or just set them in bashrc with export ...
# without export:
$ HISTSIZE=10000
$ sh
sh-5.2$ echo $HISTSIZE
500
# with export:
$ export HISTSIZE=10000
$ sh
sh-5.2$ echo $HISTSIZE
10000Last edited by frostschutz (2023-11-10 10:52:44)
Offline
Thank you, I believe just exporting the history-related envvars should be enough.
While one would not normally use sh interactively, I accidentally truncated my history several times, without knowing how.
I am now pretty sure it was because of this, and I believe I started sh to try out some commands for writing a DOCKERFILE.
Offline