Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Environment variables don't export from within scripts
Date: Mon, 02 Jan 2006 22:07:24
Message-Id: 200601022316.02738.shrdlu@unlimitedmail.org
In Reply to: [gentoo-user] Environment variables don't export from within scripts by Kris Kerwin
1 On Monday 02 January 2006 22:35, Kris Kerwin wrote:
2
3 > works. However,
4 >
5 > # echo "export VARIABLE='test'" >> test_script
6 > # chmod 754 test_script
7 > # ./test_script
8 > # echo $VARIABLE
9 >
10 > does not work. I've also tried the above while omitting the 'export'
11 > command, to the same effect. I'm using bash as my shell. I figured
12 > that I would try the same with sh instead, but still nothing.
13
14 This cannot work. Scripts cannot export back variables to their parent
15 shell, but only to their children.
16
17 Read the first note here:
18
19 http://www.tldp.org/LDP/abs/html/othertypesv.html
20
21 The following will work:
22
23 # export VARIABLE='test'
24 # echo '#!/bin/bash' > test_script
25 # echo "echo $VARIABLE" >> test_script
26 # chmod 754 test_script
27 # ./test_script # writes 'test'
28 --
29 gentoo-user@g.o mailing list