I can't say I fully understand your question, but it seems to me that you're trying to update the environment of your process through a bash
script. That's simply not possible. A child process can never modify the environment of its parent process.
And your application's process is not bash
(it's your application), so it cannot "source" a shell script. If you have an environment-setup bash
script, you have these options:
Run the env-setup script before you launch your application (perhaps launching your application through a wrapper
bash
script).Execute
bash
as a child process, have it source the script and retrieve the relevant info out from it (such as writing the environment to standard output in thebash
script and capturing its standard output in C++). For this, you might want to look atQProcess
, especially atQProcess::setReadChannel()
.