APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Mailbag: bashrc broken, can't login

© March 2005 Tony Lawrence

Author: TonyLawrence
Date: Thu Mar 10 11:57:05 2005
Subject: Mailbag: bashrc broken

Someone sent me email (don't do that if you aren't a customer - post here) with this problem:

Seems like none of the standard commands are working on my terminal 
It logs me in ok with my welcome screen but up top it reads 
Last login: Wed Mar  2 10:56:54 on ttyp1 
Welcome to Darwin! 
-bash: export: `/bin:/sbin:/usr/bin:/usr/sbin': not a valid identifier 
-bash: export: `/usr/local/mysql/bin:': not a valid identifier 
My-Computer:~ user$ 
What lead to this problem is when I was trying to install mysql on
my powermac G4, I was going off of a book of instructions from mac
OS X web development book, everything was going find up until the
last few instructions then it error msg
ERROR 1064 (42000): You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the
right syntax to use near 'PRIVILEGES ON *.* TO mysql@localhost
IDENTIFIED BY 'mypassword'' at line 1
It began to get messy before the error msg concerning bash when on
step 9 where the command is
Echo 'export PATH=/usr/local/mysql/bin: $PATH' >> ~/.bashrc 
I wasn't sure if I was even suppose to do this because I think I
already have bash and tcshrc on my mac
It followed by having me to a touch .bash_profile then ls -Ga l to
see the list which it did but then Doing .~/.bashrc ENV=$HOME/.bashrc
export ENV it got messy again and when it asked to save :w
apparently that command meant to sort and it continued to get messy
not sure what it actually did
I managed to still find my way to step 10 and it seem to accept
password but then that's when the error msg appeared
Currently, anytime I try to enter a command it reads 
-bash: command not found even to list directory still not working 
Not sure where to go from here any ideas ? 
Thank you for your time basically no commands work in the terminal
all i get is this

Welcome to Darwin!
-bash: export: `/bin:/sbin:/usr/bin:/usr/sbin': not a valid identifier 
-bash: export: `/usr/local/mysql/bin:': not a valid identifier 
I'm using mac os x 10.3.7 

What's happened is that's he's messed up his .bash_profile and possibly .bashrc

I can't really tell why from the mail; possibly bad quoting (" or ` vs ' in following the directions), but it doesn't really matter. Do this

/bin/mv .bash_profile oldbash_profile
/bin/mv .bashrc oldbashrc

Or use Finder to rename these graphically..

then logout and log in again. Figure out what happened, fix it and put 'em back.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Mailbag: bashrc broken


Inexpensive and informative Apple related e-books:

Take Control of iCloud, Fifth Edition

Take Control of Apple Mail, Third Edition

Take control of Apple TV, Second Edition

Take Control of iCloud

Take Control of the Mac Command Line with Terminal, Second Edition

More Articles by © Tony Lawrence

Fri Mar 11 02:21:29 2005: 164   anonymous

that code worked perfectly thanks my terminal is accepting comands now thanks again, now i feel guilty sorry for sending it through the email

Fri Mar 11 13:03:54 2005: 166   TonyLawrence

There's no reason to feel guilty - you offered to pay for an answer. I just knew this was simple, and more importantly could be useful to other people, so it should be a public post.

I'll answer questions here if I think the subject can be of value to other people, so why not try for a free answer first?

Sun Apr 10 17:06:57 2005: 320   anonymous

The problem was the space between the new path elements and $PATH. Shell assignments (FOO=bar:baz:quux) can't have spaces in them without being quoted (nor do you want your path to have a space in it), so bash did this:

  • Set PATH to /usr/local/mysql/bin
  • Export PATH
  • Try to export the variable named whatever the contents of $PATH are--in other words, the contents of PATH, which would be the previous contents, if I recall the order of shell evaluation correctly--which isn't the name of a variable, so bash gave the
    export: not a valid identifier

FWIW, the
command flags a variable for export to subshells. It doesn't snapshot the current value, and it doesn't require the value to be specified on that line (although that syntax is permitted in some shells).

For portability, clarity, and ease of debugging, I'd prefer to see that .bashrc snipped rewritten like this:

# PATH is already exported--no need to export it again

which has the added advantage that if the extra-space-before-$PATH typo had been made using this syntax, it would have raised an error on the assignment line and isolated it from the export command, which wasn't really the problem.

Sun Apr 10 17:10:43 2005: 321   anonymous

>Oh, lovely; all my HTML tags are visible in my post, because I entered them in capital letters just like the posting instructions say. How hideous.

Sun Apr 10 18:55:16 2005: 323   TonyLawrence

Sorry - forgot /i I'll fix..


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

The three chief virtues of a programmer are: Laziness, Impatience and Hubris. (Larry Wall)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode