Fix string splitting for the env string

This commit is contained in:
Joe Rickerby
2017-09-06 18:27:06 +01:00
parent 60ed370002
commit be474fd7f7
+12 -1
View File
@@ -23,8 +23,19 @@ def split_env_items(env_string):
['VAR="a string"', 'THING=\\'single "quotes"\\'']
>>> split_env_items('VAR="dont \\\\"forget\\\\" about backslashes"')
['VAR="dont \\\\"forget\\\\" about backslashes"']
>>> split_env_items('PATH="$PATH;/opt/cibw_test_path"')
['PATH="$PATH;/opt/cibw_test_path"']
>>> split_env_items('PATH2="something with spaces"')
['PATH2="something with spaces"']
'''
return list(bashlex.split(env_string))
command_node = bashlex.parsesingle(env_string)
result = []
for word_node in command_node.parts:
part_string = env_string[word_node.pos[0]:word_node.pos[1]]
result.append(part_string)
return result
class EnvironmentAssignment(object):