1

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

3 Answers 3

3

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

1
  • 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. Jun 12, 2011 at 6:55
2

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .