mac terminal blowup: unexpected EOF errors - macos

I've used virtualenv to program using my mac terminal for about 1/2 a year w/no issues. Suddenly today I began to get relative path errors when I tried to load python. There was no apparent reason for it, and eventually I tried restarting my computer.
Then I opened a new terminal window, and these new errors were present for the first time:
-bash: eval: line 4: unexpected EOF while looking for matching `"'
-bash: eval: line 5: syntax error: unexpected end of file
I assume the two misbehaviors are related in some way. Any idea what would be causing it? What files could the terminal be looking at that would cause this? AFIAK, I haven't changed anything on which it would depend.
Thx for any advice!

My guess is that a bash startup file (~/.bashrc, or possibly /etc/profile, ~/.bash_profile, ~/.bash_login or ~/.profile) contains a syntax error, and that causes all sorts of errors for other programs because the setup of the environment they expect does not take place.
From the error message it seems like an unterminated string constant, i.e. a missing ".
The bash manual on startup files has information about this.
You can also try to start bash in debug mode (bash -x (interactive shell) or bash -lx ( login shell)) to try to identify the error.

Related

How to fix the invalid identifier of bash?

When I open terminal, I get following error at the top.
bash: export: `/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/root/bin': not a valid identifier
I am new to linux and I was trying to execute ls command but it was not working and giving some error so I followed this answer to fix it. Now I am able to list down the file using ls command but getting this error. I wonder it will have some serious affect somewhere else or not.
Turns out my path in ~/.bashrc was not correct. So this is what I did.
gedit ~/.bashrc
After the in the opened file I update the PATH to this at the end of the file.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

How to fix the terminal "source" command on OSX Catalina

I try executing the below commands in my terminal.
$ source ~/.bash_profile or . ~/.bash_profile
and the system returns:
-bash: [[-s: command not found
I cannot think of anything extra information to provide.
I kept researching my issue and came across this stackoverflow post
I initially misunderstood the error message to mean the source command was not found. After reading the other post I tried running bash .bash_profile and the result was .bash_profile: line 11: [[-s: command not found. I had an error in my .bash_profile file. I commented out the line and tried running source .bash_profile and it worked.
The initial command not found did not relate to the source command, it related to the file I was running with source.
I hope this helps someone else.

-bash: /bin/bash:: No such file or directory

I am on Windows 10v1803, and i have WSL with Ubuntu installed and working well.
Recently, i was in vim, and appending some aliases to my .bashrc. After I finished editing, I wanted to exit without saving, did the usual Control-C, and instead of :q! I did !:q (Yes, silly typos). I realized my mistake, did the correct :q! and exited.
I came back ~1hr later, to make those 2 changes (below) and noticed that on startup, I got the error
-bash: /bin/bash:: No such file or directory
along with the normal startup
suda#suda:~$
Everything proceeds normally, but i'm concerned as to what that error means.
And, there is nothing that I could find on this apart from reinstall bash, which i have done 5 times, and makes no difference.
I proceeded to add the 2 aliases to my .bashrc, and everything works fine...
Some help as to what is happening here please?
And if you're wondering, these were what i was adding onto my .bashrc:
alias cls="clear"
alias md="mkdir"
Also, I feel that this won't go under askubuntu. If i'm wrong, please do tell me.
Edit: Here's an image
The error message is:
-bash: <file>: No such file or directory
Check that your script doesn't start with
#!/bin/bash:
and that you do not invoke /bin/bash: elsewhere, either.
(because, indeed, bash: should not exist in /bin)

-bash: ≈: command not found (OS X Terminal Error), How to Fix?

Whenever I start up Terminal on my Macbook Air, I get this message:
-bash: ≈: command not found
How do I fix this error? I'm running Mavericks version 10.9.4 if that helps at all.
EDIT: Fixed this error by using the bash -x method, found out it was a random '≈' character left in ~/.profile that needed to be deleted. Thanks for the answers :)
To debug you can try this:
bash -x -l
(the -l might not be needed).
I definitely agree with Barmar, there is something in your bash startup scripts.
There is not a great way to do this, but here is the protocol to remedy it.
Confirm it is your bash profile by first killing the process with a control + C if it is hung. Then do a source ~/.bash_profile and see if you get that same error.
Backup your bash profile cp ~/.bash_profile bashprofile.txt
Then comment out part of your bash profile. With text wrangler you can do a command + slash.
Save, then do a source ~/.bash_profile and see if the error still prints.
Repeat with different areas of the script until you have isolated the infected region.

How to get Terminal on OSX to start up clearly?

I am new to Mac OSX. Once after i typed export command in terminal, each time i start up the terminal, two messages show up:
-bash: export: '=': not a valid identifier
-bash: export: `:/Users/Li/File/Java/TStream': not a valid identifier
I know that clear and command+k can got a clean screen. But I just want to start up with a clean terminal.
Go to your terminal and type the
clear
command. This should clear your screen. Maybe what you're looking for is a way to have bash run that each time. If so, cd to your home directory:
cd ~
then edit the file called .bash_profile , or maybe .bashrc
On the last line write the word 'clear' without quotes, then save. This file runs when bash starts up, and the last thing it will do, therefore, is clear the screen.
For more info, checkout: this
EDIT:
Incidentally, I just realized you might want to clear the error. When you open up your .bashrc file, see if you can find a line that resembles the error you're getting, then comment it out.

Resources