The bashrc
was not written by me, and sources a lot of different configuration files. Upon sourcing it, I can't exit bash with Ctrl+D anymore.
I found this related question about zsh, and I would like to know the mechanism used to do the same with bash.
When typing Ctrl+D in a login shell, I get:
Use "logout" to leave the shell.
When in a non-login shell,
Use "exit" to leave the shell.
As these messages are translated depending on the locale in use, this is probably not a system script. I would like to control both independently, if possible (disable this functionality for non-login shells, for instance). Is that possible?
Best Answer
Have a look at your configuration if a either bash variables or shell options are set:
Bash Variables
(Section 5.2 in the Bash Reference Manual)
For example
IGNOREEOF=2
Modifying Shell Behavior: The Set builtin
(Section 4.3.1 in the Bash Reference Manual)
Getting to your question
Yes. Scripts you source should check if the shell is a login shell and set the variable accordingly, something like this:
Note the value of
10
still allows you to leave the shell with Ctrl+D; you just need 11 consecutive strokes of it.