35.29. Reading Files with the . and source Commands
As Section 35.4 explains, Unix programs can never, ever modify the environment of their parents. A program can only modify the environment that later will be passed to its children. This is a common mistake that many new Unix users make: they try to write a program that changes a directory (or does something else involving an environment variable) and attempt to figure out why it doesn't work. You can't do this. If you write a program that executes the cd command, that cd will be effective within your program -- but when the program finishes, you'll be back in your original (parent) shell.
you could use the following commands to change the current directory of the current shell:
% source change-my-directory $ . change-my-directory
The source and . commands read a script file into the current shell instead of starting a child shell. These commands work only for shell script files (files containing command lines as you'd type them at a shell prompt). You can't use source or . to read a binary (directly executable) file into the shell.
--ML and JP
Copyright © 2003 O'Reilly & Associates. All rights reserved.