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

Re: what's the difference between ". cmd" and "cmd" in shell script??



On Mon, Jul 21, 2003 at 09:46:54AM +0800, Zhao You Bing wrote:
> Thank u very much!!

You can only use ". cmd" when cmd is a shell script. You can not use
this syntax to run binaries or scripts written in an incompatible shell.
It will read in cmd and run it in the current shell, sort of like an
include file. The main reason some scripts do this is that cmd can
contain functions or set environmental variables for the
currently-running script.

If you use just "cmd" then cmd is run in a fork-and-exec like any
command, so if it's a shell script it'll run in a subshell. Functions
and environmental variables defined in cmd will not be available to the
currently running script.

-- 
Michael Heironimus



Reply to: