[vox-tech] Bash script to setup environment variables
Ted Deppner
vox-tech@lists.lugod.org
Fri, 28 Dec 2001 13:38:30 -0800
On Fri, Dec 28, 2001 at 08:50:03AM -0800, Ricardo Anguiano wrote:
> How about using signals? The sub-process can handle the signal by
> parsing a variable file you designate at compile time. The signal
> handler can then redefine environment variables with setenv(3).
Excellent idea! In bash, you can use trap to do this:
ted@dondra:~$ trap "echo test; echo test2" ALRM
ted@dondra:~$ kill -ALRM $$
test
test2
ted@dondra:~$ trap "a=1" USR1
ted@dondra:~$ trap "a=2" USR2
ted@dondra:~$ echo $a
ted@dondra:~$ kill -USR1 $$
ted@dondra:~$ echo $a
1
ted@dondra:~$ kill -USR2 $$
ted@dondra:~$ echo $a
2
--
Ted Deppner
http://www.psyber.com/~ted/