Skip to content

Commit 82f7e22

Browse files
Merge branch 'topic/alire_integration' into 'master'
Fix Alire integration See merge request eng/ide/gnatstudio!473
2 parents 47d7233 + c91b1ff commit 82f7e22

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

share/support/core/alire.py

Lines changed: 8 additions & 4 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")
@@ -112,7 +113,7 @@ def on_project_changing(hook, file):
112113
"""
113114
global saved_env, project_to_reload
114115

115-
if project_to_reload or "ALIRE" in os.environ:
116+
if project_to_reload:
116117
project_to_reload = None
117118
return
118119

@@ -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)