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

Re: bringing out variable



On Wed, 9 Jan 2002, Sebastiaan wrote:

> 
> #!/bin/sh
> #
> DISPLAY=:1
> export DISPLAY
> 
> 
> When I execute this script, the value is set correctly in the script
> environment, but after execution 'echo $DISPLAY' still results the old
> value. I have also tried 'set DISPLAY', without succes. Any hints?
> 
Sebastiaan,

	Where are you doing the 'echo' from? From within the script, or
from the command line after the script has been run? If the latter, then
what you see is to be expected. When any program or shell script is run,
a new shell is first spawned and the program / shell gets executed within
that shell. Any 'export' that you do from the script will therefore only
be visible to processes that are descendants of the shell running that
script. The shell from which it was invoked will not have its env. changed
at all.

	In order to do what you want, you need to use the 'source' builtin
function of bash (man bash and search for 'source filename'). The
alternative syntax for 'source' is to use '.' in place of the word
'source' .

Regards,
Jor-el



Reply to: