What does this example bash startup script do?

Posted by Dimitri on Super User See other posts from Super User or by Dimitri
Published on 2012-06-22T19:04:02Z Indexed on 2012/06/22 21:18 UTC
Read the original article Hit count: 225

Filed under:
|
|

I am trying to set up GNU Octave on my computer (Mac OS X 10.7.4). I am newbie in using Terminal and I need help to understand what the following script actually does:

if [ -f ~/.bashrc ];then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. ~/.bashrc<br>
fi<br>
PATH=$PATH:/usr/local/bin<br>
BASH_ENV=~/.bashrc<br>
export BASH_ENV PATH<br>
export GNUTERM=aqua<br>
alias octave="/Applications/Octave.app/Contents/Resources/bin/octave"<br>
alias gnuplot="/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot"<br>

(taken from here: http://wikibox.stanford.edu/me112/index.php/Main/OctaveMatlabNotes)

So this script begins with the simple conditional if statement. I don't understand the conditional expression - what is -f and .bashrc? What the statement . ~/.bashrc actually does?

Then 2 variables are defined PATH and BASH_ENV. Why are they exported? Why GNUTERM=aqua is exported even if it's not defined anywhere?

All I need is a script that would allow me to run Octave by simply typing octave in the terminal. I don't need an alias for the gnu plot.

Thanks

© Super User or respective owner

Related posts about mac

Related posts about bash