Each default shell (the program that runs inside the terminal application) has two startup files.
If you look at the steps you performed when you set up homebrew, it asked you to modify those startup files. There is a syntax error or unintended side effect of the directions you followed to customize the files to prepare the homebrew environment. Look for lines containing eval or shellenv specifically.
- Take some time and change each line looks like it matches those strings - or systematically delete lines you think you understand what they do from your startup file and then test. Make one change, save the file, test. This is the path of learning your way out of this mess. This also could break your shell - so all manner of breakage can happen with an error in your startup scripts (or worse a loop).
- Throw away the startup files - go slower or with someone as you edit the shell startup files using
brew doctor as guidance. This is safer if you don’t really know what you’re doing editing the files.
This “situation” happens to about 95% of the people learning how to set up a shell, so you might choose to pair up with someone that can work with you and show you the ropes or find a guided intro that explains how to debug your shell startup files. Eventually everyone breaks their environment with copypasta - even if the instructions were not malicious.
To clear the deck, if you know your backup of this Mac is current, just move the files to /tmp (kind of a junk drawer for shell files) and the log out (Apple Menu - log out of your entire graphical session) log in and try setting up your “dot files” again, slowly and making one line change at a time.
mv ~/.bashrc ~/.bash_profile ~/.zprofile ~/.zshrc /tmp
Files in /tmp clear at boot so it’s not a good place for long term storage. It is very temporary and not a backup.
What that command does is move both bash and zsh startup files out of the way. I chose those two since they are the default shells covering recent macOS releases. If you chose a different shell or had setup already done, this will undo those settings.
Good luck in this “choose your own adventure” situation - there’s no wrong choice (although not backing up is a radical choice for some), and welcome to the team that wraps their brain around the wonderful world of shell programming using the unix idiom of computing.
echo $0and tell us the result. – nohillside Mar 26 '21 at 11:41-xturned on. You will probably get plenty of output, but you will quickly see which command causes those lines to be printed. Alternatively, you could also try a simplezsh -xlin your current shell. Chances are that the problem will be reproducible, and you don't have to fiddle with your Terminal configuration. – user1934428 Jun 15 '22 at 13:29