My Bash Terminal is stuck after a bad command.

Even opening new shell instances (cmd T) starts the same hangup ending with a [Process completed] message.

It's rendering bash terminal unusable (cannot type or run any other process). How can I kill the hangup process?

Note: ^C, ^D, ^Z do not work.

enter image description here


This is on macOS, right?

As it's difficult to edit the file from a terminal (owing to the fact that the shell will immediately exit), open the file you previously modified (probably ~/.bashrc, ~/.bash_profile, or ~/.profile), from the Finder, in a text editor, and correct the error.

You should be able to toggle the listing of hidden files in any "Open File" dialog box, or in the Finder itself, by pressing ⌘ CMD+⇧ SHIFT+..

Another option is simply to rename the file that you think is causing the issue. Again, do this from the Finder.

Speculating on the cause:

You may have inadvertently executed exit, possibly unconditionally, or through following some logic branching. Or you may have used set -e or set -o errexit and then had a utility exit with a non-zero exit status (i.e. failing).

  • Might be easier to simply rename the potentially offending file(s) rather than trying to shoehorn them into TextEdit without accidentally making them non-plaintext files.
    – DopeGhoti
    Sep 26 '17 at 20:18
  • @DopeGhoti That's another good option.
    – Kusalananda
    Sep 26 '17 at 20:23
  • probably calling exec xyz
    – user282164
    May 31 '19 at 3:19
  • 1
    @OlegzandrDenman That would probably have changed the terminal's tab name, but it still says -bash (i.e. it's a bash login shell process running).
    – Kusalananda
    May 31 '19 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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