Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3205,6 +3205,14 @@ def __init__(self, asFilename, enmBuildTarget = None, oEnvMgr = None, cchKeyAlig
super().__init__(asFilename, enmBuildTarget, oEnvMgr, cchKeyAlign);
self.sKeyword = 'set' if enmBuildTarget == BuildTarget.WINDOWS else 'export';

def formatValue(self, sVal):
"""
Formats an environment variable value for the target shell.
"""
if self.enmBuildTarget == BuildTarget.WINDOWS:
return sVal;
return shlex.quote(sVal);

def write(self, sKey, oVal = None):
"""
Writes an environment variable appropriate for the platform.
Expand All @@ -3216,12 +3224,12 @@ def write(self, sKey, oVal = None):
sValStr = ' '.join(map(str, oVal));
else:
sValStr = str(oVal);
super().write_raw(f"{self.sKeyword} {sKey}={sValStr}");
super().write_raw(f"{self.sKeyword} {sKey}={self.formatValue(sValStr)}");
return;

if sKey in self.oEnvMgr.env \
and sKey is not None:
super().write_raw(f"{self.sKeyword} {sKey}={oVal if oVal else self.oEnvMgr[sKey]}");
super().write_raw(f"{self.sKeyword} {sKey}={self.formatValue(oVal if oVal else self.oEnvMgr[sKey])}");

def write_all(self, asPrefixInclude = None, asPrefixExclude = None):
"""
Expand Down