Fix reading environment variables with newline

Summary:
Use '\0' as separator as '\n' is likely to appear in values.

BUG: 413130

Test Plan:
/etc/profile.d/mc.sh exported an mc() function,
which resulted in "syntax error: unexpected end of file" in the Plasma session.
Now the mc function is correctly set in the environment.

Reviewers: #plasma, apol, davidedmundson, adridg

Reviewed By: #plasma, apol, davidedmundson, adridg

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24750
wilder-5.17
Fabian Vogt 6 years ago
parent 1be4bb880f
commit 595ab88bc2
  1. 2
      startkde/plasma-sourceenv.sh
  2. 2
      startkde/startplasma.cpp

@ -3,4 +3,4 @@ do
. $i >/dev/null
done
env
env -0

@ -91,7 +91,7 @@ void sourceFiles(const QStringList &files)
p.waitForFinished(-1);
const auto fullEnv = p.readAllStandardOutput();
auto envs = fullEnv.split('\n');
auto envs = fullEnv.split('\0');
for (auto &env: envs) {
if (env.startsWith("_=") || env.startsWith("SHLVL"))

Loading…
Cancel
Save