How can I terminate the running sudo command that always reopens? When i open a new window in terminal i get this: !


I was trying to install MacPorts approximately a year ago and that did not go well. 

Since i don't use terminal very often I just left it that way.

Now I would like to have it working again!

I tried to delete the com.apple.terminal.plist file and I am stuck.

When I enter my password the shell turns from sudo to tee and everything I enter is just repeated!



When I don't enter my password I get a useable shell.
What can I do to prevent the sudo command from reopening?
What you have is a bad set of shell startup files, so the first thing to do is regain control of your Mac.


Do not log out or reboot (just in case the damage will prevent a new log in - unlikely, but why risk it - especially if you don't have a good backup)
Open System Preferences
Make a new Admin account and enable fast user switching
Save whatever work in other apps you cannot afford to lose
Use the menu bar to log in as the new admin account


At that point, you'll know if that new user has full shell access or if you somehow messed up the files that set up all user shell processes.

You can go about removing MacPorts from the new user as well as be sure you have a good backup before you go in to clear the files that are messing up your current user's shell login process. Since your port install isn't functioning - try to run the port uninstall, but proceed with the manual rm command to actually remove the items in /opt and elsewhere that were installed.

http://guide.macports.org/chunked/installing.macports.uninstalling.html

At that point, you can also try cleaning up files elsewhere - here are the files MacPorts should have changed on you, so you may have to delete all of these and/or recover them from a clean instal or a backup from before when MacPorts touched them:


  Depending on your shell and which configuration files already exist, the installer may use .profile, .bash_login, .bash_profile, .tcshrc, or .cshrc.


The cleaning for you might also involve:

cd /Users
sudo -s
cd broken
tar -cvf ./bash_broken.tar .bash*
rm -i .bash*


That will make a backup tar file of all your broken bash startup files (.bash_history, .bahsrc, etc…) Be careful with the sudo - if you rm the wrong file, there is no trashcan or undo. The -i flag will have rm ask you if you want to delete each file. You want to remove pretty much all of them except maybe the history file (so you can look back at what you did in the past if needed).

Once you've removed the files, log out of the new user and back into the old user and see about whether that fixed your terminal problems.