[NTLUG:Discuss] OT - include bash script

Eric Waguespack ewaguespack at gmail.com
Tue Jan 5 17:36:50 CST 2010


On Tue, Jan 5, 2010 at 3:22 PM, Greg Edwards <greg at nas-inet.com> wrote:
> Is it possible to have a bash script include code from another file and
> maintain vars set by the parent script?
>
> example:
>
> parent script:
>
>   message="hello world"
>   $include child.inc
>
> child.inc:
>
>   echo The message of the day is $message
>
> The $include directive pulls the code fine, but vars set by the parent
> are lost.  In the above example $message is empty.
>
> --
> Greg E

source child.inc
# or
. child.inc



More information about the Discuss mailing list