Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Prevent accidental terminal logouts in the bash shell UNIX

Typing Control-D on the command line has a different effect depending on the context. It is often used to send an EOF character to a particular command (when redirecting standard input to a file using cat, for example). Using emacs mode in the bash shell (the default mode), Control-D deletes one character forward. But if the command line is empty, it will log you out of the shell. To avoid this, add the following line to your .bash_profile:

  shopt -s -o ignoreeof
Now if you accidentally type Control-D on an empty command line, you will remain logged in and be presented with this friendly reminder:

  Use "logout" to leave the shell.
Control-D will still work as expected in other contexts.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,309 views]  

Prevent accidental terminal logouts in the bash shell | 1 comments | Create New Account
Click here to return to the 'Prevent accidental terminal logouts in the bash shell' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Prevent accidental terminal logouts in the bash shell
Authored by: mervTormel on May 01, '03 02:35:52PM

~/.bashrc:

IGNOREEOF=1 # number of extra consecutive eof's to exit a shell

so, IGNOREEOF+1 consecutive ^D's will logout the shell



[ Reply to This | # ]