From f0c3f2ce0cdb405945c622fb3bf9502139e43ec9 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 24 Jun 2014 13:32:25 +0200 Subject: [PATCH] Variables: Use %{Env:SOME_NAME} to access environment variables Change-Id: I2291e91608f9a93b7c886890a1e1039c5002f4ce Reviewed-by: Orgad Shaneh Reviewed-by: Eike Ziller --- src/plugins/coreplugin/variablemanager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/coreplugin/variablemanager.cpp b/src/plugins/coreplugin/variablemanager.cpp index d66737cbc2c..aa4fbcda818 100644 --- a/src/plugins/coreplugin/variablemanager.cpp +++ b/src/plugins/coreplugin/variablemanager.cpp @@ -81,6 +81,9 @@ public: When the variable manager is requested to replace variables in a string, it looks for variable names enclosed in %{ and }, like %{CurrentDocument:FilePath}. + Environment variables are accessible using the %{Env:...} notation. + For example, to access the SHELL environment variable, use %{Env:SHELL}. + \note The names of the variables are stored as QByteArray. They are typically 7-bit-clean. In cases where this is not possible, UTF-8 encoding is assumed. @@ -191,6 +194,12 @@ VariableManager::~VariableManager() */ QString VariableManager::value(const QByteArray &variable, bool *found) { + if (variable.startsWith("Env:")) { + QByteArray ba = qgetenv(variable.data() + 4); + if (found) + *found = !ba.isNull(); + return QString::fromLocal8Bit(ba); + } if (found) *found = d->m_map.contains(variable); StringFunction f = d->m_map.value(variable);