TCL script
set ::env(foo) "bar"
bash script
echo ${env(foo)}
echo $foo
I am able to print the environment variable in the TCL script but for some reason I can't print the environment variable in my bash script. What am I doing wrong?
If your bash script contains something like this (let's call it showenv)
#! /bin/bash
echo $foo
and your tcl
#! /usr/bin/tclsh
set ::env(foo) bar
exec ./showenv >>& /dev/tty
then, showenv will show
bar
that is, the tcl script sets the environment for its children processes.
foois in the environment of your shell, it's simplyecho "$foo". On startup, the shell simply defines a regular shell variable for each name in the environment that forms a valid shell identifier.