I am unable to make even the simplest export of variables, from within scripts, to work in my bash – what am I dooing wrong?
File test.sh :
#!/bin/bash
echo $ttt
ttt="fffalse"
export ttt
echo $ttt
bash test :
hpek@hpek:~/temp$ export ttt="tttrue"
hpek@hpek:~/temp$ ./test.sh
tttrue
fffalse
hpek@hpek:~/temp$ ./test.sh
tttrue
fffalse
hpek@hpek:~/temp$
Edit:
I now know from the answers, that this will not work. -but how can make a single variable remembered between processes? Do I need to store it in a file?
./test.shis the same asbash test.shEach shell script running is, in effect, a subprocess (child process) of the parent shell.
And subprocess cannot export env-var to it’s parent.
You can try this(run in the same environment):