"Point", that is, as in the `.' command, aka `source'. What's it for?
"Read and execute commands from the FILENAME argument in the current
shell context.", accoring to the bash.info. "Current shell context"?
In the bash man page, we get "Read and execute commands from filename in
the current shell environment and return the exit status of the last
command executed from filename." What the flowerpot full of flying
fuchsias is a "current shell environment" supposed to be?
Going to Newham's and Rosenblatt's "Learning the Bash Shell", we discover
that "_source_ executes the commands in the specified file, ...".
Wonderful? Why not just type the file's name, and save the 7 characters
involved in typing "source "? This book is supposed to be a tutorial
book. (I heartily recommend any beginners to choose some other book
instead. It would appear it's authors didn't understand `.' when they
wrote their book. It's not the only thing they seemed not to
Well, I found out the answer to this question on Tuesday. If you call a
script with `.' (or `source'), variables set within the script stay set
when the script finishes. Otherwise, the changes are lost. On Tuesday,
I had written a script with several lines like:
export BUILD_BASE = /home/AM/foo/me/bar/dev/start/here/thingy/base
, because it was kind of tedious to type them all by hand, time after
time. Of course, it didn't work. At least not until it was called
pointedly. Are there any other good reasons for using `.'?
Look at the way "export" is defined in these three places, and that's not
much more help. Essential to a description of "export" is a statement
that the value given a variable is only exported to scripts called from
the current one, and that it's value is lost at the end - it's a sort of
"internal export" only.
"Learning the Bash Shell" is hopeless here. It merely says "Any variable
can become an environment variable. First it must be defined as usual;
then it must be _exported_ with the command: `export varnames'".
The bash info page is a bit better, saying "Mark each NAME to be passed
to child processes in the environment.". But what about child processes
which _aren't_ in the environment? ;-(
So - Are there any books/web pages which clearly describe `.', `source'
and `export' without first requiring it's reader to have a mental model
of environments and contexts and suchlike first? It'd be nice to hear
Alan Mackenzie (Munich, Germany)
(like "aa"), remove half of them (leaving, say, "a").