-bash: [: missing `]' whenever I start the terminal - macos

For some reason, I get this message
-bash: [: missing `]'
when I open a new terminal, does anyone know why this is happening?

You should check all the scripts that are started by login
.profile
.bashrc
.bash_profile
If other users are affected then also
/etc/profile
/etc/bashrc
In one of them there is a statement calling test with [ without a closing bracket ]. Search for all [ and check if they are properly closed.

Related

Why is my vim bash command auto-completion reporting error?

Hi today for unknown reason, if I typed the following command "vim \tab" in bash terminal to hopefully get an auto-completion, I get the following error:
$ vim bash: command substitution: line 22: syntax error near unexpected token `}'
bash: command substitution: line 22: ` }'
This error does not happen if I typed '\tab` at the end of other commands such as 'ls', or even an alias of vim such as 'alias v=vim'.
This error does not happen in another gnome-terminal, either.
Not sure what is causing this (a vim plugin?). Any idea? thanks.
Found the root cause. I created an alias done, and the "done" conflicts with the bash keyword "done". Problem solved by renamed the alias.

Terminal Bash Error on startup

Every time I launch terminal, I keep getting this syntax error.
-bash: /Users/Jake/.bash_profile: line 2: syntax error near unexpected token `then'
-bash: /Users/Jake/.bash_profile: line 2: `alias mysql='/Applications/XAMPP/xamppfiles/bin/mysql'if which rbenv >
/dev/null; then eval "$(rbenv init -)"; fi'
How do I fix this?
if you don't want that alias just edit your /Users/Jake/.bash_profile and remove or comment that line with a # at the begininning . If you do want that alias please post your .bash_profile so we can look at what the error is.
Hope it helps

/.profile "Unexpected EOF while looking for matching `" '

I am new to the terminal and have been working towards adding Grunt to my workflow. I am receiving this error in my Terminal and I don't see any missing " in my .profile file.
-bash: /Users/shawnwilliams/.profile: line 4: unexpected EOF while looking for matching `"'
-bash: /Users/shawnwilliams/.profile: line 6: syntax error: unexpected end of file
Here is my .profile (Edited as I provided the wrong file.)
export PATH="$PATH:$HOME/.rvm/bin:/usr/local/bin” # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
It looks like you're using a non-ascii double-quote character after /usr/local/bin. Try changing the double quotes to ascii.
The issue is in your .profile, not .bash_profile, as indicated by the error message.
your .profile is sourced in the first line and then bash complains.

.bash_profile aliases: command not found

I cannot get my .bash_profile aliases to work on my Mac OSX Terminal. I created a .bash_profile file in my ~/ directory, then wrote two lines:
echo bash profile has loaded
alias prof=“open ~/.bash_profile”
I saved and entered in Terminal command:
. ~/.bash_profile
Terminal displayed:
bash profile has loaded
-bash: alias: /Users/kennethlarose/.bash_profile”: not found
I've been reading up on alias profiles, and I believe my syntax is valid. I know the profile is sourcing because it displays the echo, but Terminal will show the same 'not found' message no matter what command I save in the alias. Does anybody know what else I can try?
Let's ask shellcheck!
In .bash_profile line 2:
alias prof=“open ~/.bash_profile”
^-- SC1015: This is a unicode double quote. Delete and retype it.
There's your problem. OS X has turned your double quotes into fancy slanted quotes that bash doesn't recognize. If you're programming, you may want to disable "smart quotes".

mac terminal blowup: unexpected EOF errors

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.

Resources