Skip to content

Commit 7890894

Browse files
Make sure to unquote 'alr printenv' paths
Alire now quotes all the paths in the 'alr printenv' output: make sure to unquote them before calling GPS.setenv to reload the project with the right Alire environment. For eng/ide/gnatstudio#30
1 parent 47d7233 commit 7890894

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

share/support/core/alire.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os.path
1212
import re
1313
import tool_output
14+
import shlex
1415
from gi.repository import Gtk
1516

1617
alr = os_utils.locate_exec_on_path("alr")
@@ -138,7 +139,7 @@ def on_project_changing(hook, file):
138139
class Alire_Parser(tool_output.OutputParser):
139140
"""
140141
Parse the Alire output in oder to set the needed environment,
141-
saving the original environment in order to restor it if needed.
142+
saving the original environment in order to restore it if needed.
142143
"""
143144

144145
def __init__(self, child=None):
@@ -152,8 +153,11 @@ def on_stdout(self, text, command):
152153
m = self.exp.fullmatch(line)
153154

154155
if m:
156+
# Parse the output of 'alr printenv'.
157+
# The paths might be quoted (e.g: export PATH="/home/something"): we use
158+
# shlex.split to make sure we unquote them if needed.
155159
name = m.group(1)
156-
value = m.group(2)
160+
value = shlex.split(m.group(2))[0]
157161
GPS.Logger("ALIRE").log("%s=%s" % (name, value))
158162
saved_env[name] = GPS.getenv(name)
159163
GPS.setenv(name, value)
@@ -168,7 +172,7 @@ def on_stdout(self, text, command):
168172
GPS.parse_xml(
169173
"""<?xml version="1.0"?><ALIRE>
170174
<target-model name="Alire" category="">
171-
<description>Laubch Alire to print environment</description>
175+
<description>Launch Alire to print environment</description>
172176
<command-line>
173177
<arg>alr</arg>
174178
<arg>--non-interactive</arg>

0 commit comments

Comments
 (0)