Sourcing a script using QProcess
-
Hi
is source a standalone program/command ?
else it wont work as QProcess
have no idea how to run it
if internal bash command.
( I think )
maybe:
Process.start("bash", QStringList() << "-c" << "source" << "myscript.sh "); -
Hi,
I haven't tested source with QProcess but in any case the correct call would rather be:
p.start("source", QStringList() << "/path/to/myscript.sh");
Give the full path to myscript.sh. You are likely using a shadow build so myscript.sh will not be in the same folder as your application.
-
Try with
p.start("bash", QStringList() << "-c" << "\"\"source /path/to/test.sh\"\"");
-
How are you checking that it does nothing with QProcess ?
In the console version you have too much quotes it should only be
bash -c "source /path/to/test.sh"
-
How are you checking that it does nothing with QProcess ?
The env vars are not exported and there is no echo.
In the console version you have too much quotes it should only be bash -c "source /path/to/test.sh"
Yes, in this way the echo is shown but the vars are not exported. It's the same as run the script directly without sourcing it. But it's beyond my knowledge to understand why.
-
On OS X putting the echo call inside the "command string" worked.
I'm reading stdout using readAllStandardOutput
-
You can set the environment using
QProcess::setProcessEnvironment(const QProcessEnvironment & environment)
You can get the environment of your current process via
QProcessEnvironment::systemEnvironment()