|


| NAVIGATION |
|
Home |
|
Store |
|
|
| INSIDE MAC |
|
Television Shows |
|
Broadcast Shows |
|
Daily News Shows |
|
Special Shows |
|
|
| EVENTS |
|
|
|
|
|
|
|
|
| DAILY TIPS |
|
Design |
|
Mac OS X |
|
Mac OS X UNIX |
|
|
| COMMUNITY |
|
Surveys |
|
|
| NEWS |
|
Current |
|
Press |
|
Archive |
|
|
| FEATURES |
|
Editorial |
|
Dr. Mac |
|
Reviews |
|
Reader Reports |
|
|
| RESOURCES |
|
FAQ |
|
Documentation |
|
Learning Center |
|
MAN pages |
|
Glossary |
|
Tutorials |
|
Tips |
|
Links |
|
|
|

|
|
|
OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 105 - Controlling Bash At Startup (18 April 2005)
by
Adrian Mayo - Editor, OSXFAQ
Friday - Script vs 'source' vs '.'
Executing a script in the usual manner from the command line:
$ name-of-script
executes the script in a new bash shell. If you want a script executed by the current shell you must 'source' it:
$ source name-of-script
or
$ . name-of-script
Executing an initialisation script like /etc/bashrc instead of sourcing it will not work. When the new shell ends all its environment and shell variables are destroyed.
If you need to keep track on which initialisation scripts have been run in any one shell environment, use the following technique.
To /etc/profile add:
declare -x STARTUP="/etc/profile, "
To /etc/bashrc add:
declare -x STARTUP="${STARTUP}/etc/bashrc, "
and similarly to ~/.bash_profile add:
STARTUP="${STARTUP}~/.bash_profile, "
and to ~/.bashrc add:
STARTUP="${STARTUP}~/.bashrc, "
Any other sourced files such as those from Fink should also have similar statements added.
If you want to learn more about Mac OS X Unix visit the Learning Center
click.
- For beginners: Mac OS X Unix Tutorials
- For detailed information on specific topics: Advanced Unix
- For OS X in gereral: Mac OS X Tutorials
|


|
Copyright © 2000-2010 Inside Mac Media, Inc. All rights reserved. |
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users. |
| Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc. |
|