Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On Unix bash, when I run stty intr ^M (^M is Control-M) I have effectively blocked myself from running any commands. Whenever I press the "return" key, I am sending the interrupt signal to the shell and my command is never run. Suppose I had this in my .profile (I don't actually..); how could I get myself out of this hole from a bash session with ^M set to trigger an interrupt signal?

Chris

share|improve this question

migrated from stackoverflow.com Jun 12 '11 at 6:58

This question came from our site for professional and enthusiast programmers.

3 Answers 3

In general (i.e. if things are even more messed up than this and you don't know how else to fix them), you can run stty from another tty using

stty sane < /dev/whatever
stty intr ^c < /dev/whatever

If you're not sure what tty has the messed up settings, use who or ps to find out what ttys you are using, and just stty < /dev/whatever each one in turn until you find the one that's wrong.

share|improve this answer

I was going to suggest stty sane ^J, but that doesn't reset the interrupt. You'll have to do something like this:

$ stty intr ^C^J

The ^C stands for the Control-C. You can usually get that by pressing Control-V/Control-C.

share|improve this answer

bash has both ^M and ^J bound to accept-line by default, so you can use either.

share|improve this answer
1  
So stty intr ^c^j works. You can also use ^v to 'escape' the ^m, so stty intr ^c^v^j works. The only oddity there is that the ^j and ^v and ^m have to be control-key codes; the ^c can either be a control-key code or two characters, caret and v. –  Jonathan Leffler Jun 12 '11 at 6:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.