Bash, bashrc, and 10.1

kilowatt

mach-o mach-o man
I've had bash installed on my mac since the early days of X, but after upgrading to 10.1, when I bring up a new terminal window (it is supposed to load /usr/local/bin/bash as my shell), my .bashrc file isn't read.

Now, if I enter the terminal, and type bash, I get a new shell of bash, and it does read it. So why doesn't .bashrc get read when terminal opens bash for me?

(I noticed this because my path and prompt were different than usual, not to mention all my aliases were not working)
 
Do this one, and it'll be working again. It should have been required for 10.0.x as well:

echo "source ~/.bashrc" > ~/.profile
 
...nice...

so can you use 'source' in most shell-script-like functions? Looks like a very useful command.

Thanks!
 
I'm not sure if it's only in bash (and sh), or if tcsh and other shells use it as well. I'm thinking other shells use source as well, but I can't remember - I've pretty much stuck to the bash shell. I don't really like the other ones available. ;)

Heh, my first OS X compile was for bash.

You can also include other shell scripts in your shell script by doing

. /path/to/other/shell/script

That's a great feature too! :D
 
the "source" command also works with tcsh as well.

Incidently, for those of you that wish to learn the shell a lot better, check out this book for Csh and Tcsh..

"The Unix C Shell Field Guide" by Gail Anderson and Paul Anderson
ISBN 0-13-937468-X

It is an excellent learning resouce for shell programming. Once pick this one up, bash and other shells are a snap to learn.

bob..
 
The "source" command is also used by csh and tcsh, but the Bourne shell (sh) and Korn shell (ksh) use the "." command to source a file. For example,

In csh:

source ~/rcfile

In ksh:

. ~/rcfile
 
"I hate UNIX (but this book makes it better" is a great unix startup book. Although centered arround solaris 2.x (I think), its invaluable when you don't feel like looking through the man page for a silly option. The book is also pretty darn funny. Imagine, a computer book written by a woman... you know its going to be different ;-)

"UNIX: System V" another straight forward references, although its a bit old.

I've got a few others.. but they are all 20 miles away! I'll post them here when I get them.

Oh, and I wouldn't bother with any of the Mac OS X books comming out now because Mac OS X is changing so much, it wouldn't be worth learning and relearning (and spending money...) But the old unix books are easy to adapt, and are helpfull on many systems. I buy mine at yard sales and ham fests for usually $2 a piece.
 
Back
Top