getting shell variables in parent-shell which were defined in a sub-shell

getting shell variables in parent-shell which were defined in a sub-shell

Post by dtekle200 » Sat, 01 Mar 2008 01:22:51


Hello,

I have following problem:

I need to define a bunch of shell variables in a shell script, so I
decided to put all the set commands
in a seperated shell script file which I wanted to execute in my main
shell script.

Unfortunately all shell variables which were defined during execution
in the sub-shell
are unknown to the parent-shell.

My question is if there is any way to do things this way. (perhaps
using another shell-flavour?)

Thanks in advance


--------------------------------------
main shell script (executed in parent-shell):
#!/bin/tcsh
...
definemyvariables.sh
...


shell script for defining my variables (executed in a sub-shell):
#!/bin/tcsh
set $myVar = Value
...
 
 
 

getting shell variables in parent-shell which were defined in a sub-shell

Post by pk » Sat, 01 Mar 2008 01:42:28


If tcsh can source scripts (I think it can), then just source it, ie:

source definemyvariables.sh

 
 
 

getting shell variables in parent-shell which were defined in a sub-shell

Post by dtekle200 » Sat, 01 Mar 2008 16:23:26

Hello again,

I oversaw that obvious solution. My script works now.

Thanks for your fast answers.