what is the difference?
Nifty Hat Mitch
mitch48 at sbcglobal.net
Wed Sep 8 06:31:52 UTC 2004
On Fri, Sep 03, 2004 at 06:14:56PM -0700, Deepak Oberoi wrote:
>
> what is the differecne between the following?
> . /etc/sysconfig/sendmail
> and
> ./etc/... (i know if the "." is followed by "/" then
> it executes the file but dont know the what it does if
> space is present between . and /)
This is a good question. You will see the " . file " construct
used in lots of system shell scripts.
In effect the . causes the following file to be 'sourced' or read
as commands. This permits a set of shell scripts to share
common functions, setup and configuration flags.
Many of the scripts in /etc/init.d do this. Read some of them...
The other form executes the file and returns and exit status (only
exit status and side effects impact the current shell).
The key difference is that the " . file" is executed by the current
shell and the second is executed by a sub shell and returns only
an exit status.
For csh users the keyword "source" is the equivalent to " . " for
sh and bash users.
I use the "dot" construct to setup my environment for some
projects. Something like:
. projX
Where projX contains lines like
export PROJXPATH=$HOME/projX
PATH=$PATH:$PROJXPATH/bin
export BUILDPATH==$HOME/projX/src
export PROJXFLAGS=" -j -fullwarn -kit -kabootal"
pushd $PROJXPATH
export NAME=My-Proj-X-identity
newrole -r projX_r # see SELinux
The idea is to place all the junk that is project specific in one
place. This keeps conflicts with other applications, projects and
tools (like projY) at a minimum.
--
T o m M i t c h e l l
Just say no to 74LS73 in 2004
More information about the fedora-list
mailing list