Re: what does export do?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--On Friday, May 20, 2005 11:00 PM +0100 THUFIR HAWAT <hawat.thufir@xxxxxxxxx> wrote:

"source the script" means write a script?  pardon, would you expand on
that sentence, please?

When you "execute" a script by typing its name at the command line, the current shell spawns another shell as a child process to interpret and run the script. Sometimes you want to run the commands in a script in the current shell, not in a child. For Bash you can do that by putting ". " (dot space) in front of the script's name. The dot command is built into the shell and reads commands from its argument filename, executing them directly.


For instance, if you have a script that sets shell variables, you don't want to run it in a subshell (a child process) as that won't affect the variables in the current shell. Instead, you want want to "source" it into the current shell, running it as if you typed its contents in at the prompt.

A common use of this in Fedora is in the initscripts in /etc/rc.d/init.d. They source scripts full of program settings from scripts in /etc/sysconfig.



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux