1

I was installing Apache Ant earlier and once I did, I also ran:

touch ~/.bash_profile
nano .bash_profile

Within that text file I wrote:

. .bash_profile

saved, exited, then ran:

source ~/.bash_profile

Now my Terminal looks like this:

I can't access my command line at all, so I went into preferences and set

/bin/bash -x

to run as a default upon Terminal's open, and now it looks like this:

and still reads

[Process Completed]

afterward. Any help?

7

You've got a recursive inclusion in your .bash_profile.

You can always edit the file in TextEdit.app (or another graphical text editor of your liking) if you get in to deep trouble like this.

Open up TextEdit using Spotlight or via Finder and then type ⌘ CMD+o to get the Open File... dialog. Press ⌘ CMD+⇧ SHIFT+. to reveal hidden files in the dialog box and then find your ~/.bash_profile file. Remove the:

. .bash_profile

from the file and save it and you'll have a working bash shell again.

1

The simplest way to get to a shell without running startup commands is to use Terminal’s

Shell > New Command…

to run bash --noprofile. This tells Bash not to run the login startup script. Other shells have similar options, e.g., zsh --no_rcs.

This avoids changing preferences and only affects a specific terminal, which you can then use to edit startup scripts or other configuration files that are causing problems.

0

I fixed it using:

/bin/zsh

as the default command upon open(with 'run in shell' unchecked). Then:

rm ~/.bash_profile

Then change default command upon open back to:

/bin/bash
  • 1
    You can also edit the file directly with an editor like Sublime, if you can't initiate a shell. – etc Aug 9 '15 at 4:47
0

Your .bash_profile is called automatically as your terminal loads. The . command is the same as source, it calls the shell script and loads it into the environment of the calling shell (as opposed to a child shell).

So what you have here is the bash profile script being called recursively. You can open it another text editor and remove the offending . .bash_profile. There are several technique to seeing or opening hidden files from Finder.

If the script is on a remote box, then you will need to find another shell to edit the profile script.

You must log in to answer this question.

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