1111import os .path
1212import re
1313import tool_output
14+ import shlex
1415from gi .repository import Gtk
1516
1617alr = 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):
138139class 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