From: Ctalk Project on
Warren Oates <warren.oates(a)gmail.com> writes:

> In article
> <545ec116-c67d-4505-8fbe-0fb29c2127c2(a)i37g2000yqn.googlegroups.com>,
> "laredotornado(a)zipmail.com" <laredotornado(a)gmail.com> wrote:
>
>> However, when I restart my system and go into my terminal, I'm not
>> able to echo the values for the variables I defined ...
>>
>> -bash-3.2$ echo $JAVA_HOME
>>
>> -bash-3.2$
>>
>>
>> What am I doing wrong? Thanks, - Dave
>
> In your home directory (User/you) create a file called .bash_profile,
> and put this in it:
>
> if [ -f ~/.bashrc ]; then
> source ~/.bashrc
> fi
>
> Then create a file called .bashrc and put your stuff like
>
>> export JAVA_HOME=/Library/Java/Home
>> export CATALINA_HOME=/Library/Tomcat/Home
>> export PATH=/opt/local/bin:/opt/local/sbin:$PATH
>> export MANPATH=/opt/local/share/man:$MANPATH
>
>
> in .bashrc. I'd do this though:
>
> JAVA_HOME=/Library/Java/Home
> PATH=/opt/local/bin:/opt/local/sbin:$PATH
> export JAVA_HOME PATH
>
> and so on.
>
> Note the dots which start the files. Leave the /etc/profile file alone.
>
> There's some old unixie reason why you do it this way.

Hmmph. Bash has been around for a long time now. It is
originally designed for *NIX, not OS X, so the reason for
these conventions might not be immediately obvious. For
example, though, on login (on a *NIX) system, the shell
should start a program like a window manager only once. But
when starting another non-login shell (say, for example, by
opening a terminal window), the system doesn't need to start
additional instances of the desktop-wide programs, but only
the initialization for thqt specific terminal window. Often
though, with *NIX systems, the desktop display is launched
by a session manager, in which case programs and scripts can
also be launched variously by ~/.xsession and ~/.xinitrc.
But I'm digressing there. Recent bashes can also read
/etc/profile and ~/.profile using a Bourne-shell
"compatible" mode. So some RTFM'ing ("man bash" in a
terminal window) for the specifics of the particular system
should clarify that. HTH, Robert

--
Ctalk Home Page: http://www.ctalklang.org