Make shell evals work and add tests for that

This commit is contained in:
Joe Rickerby
2017-09-02 22:09:32 +01:00
parent f64cb35d22
commit f56ddda157
4 changed files with 67 additions and 30 deletions
+1 -14
View File
@@ -35,22 +35,9 @@ class EnvironmentAssignment(object):
self.name = name
self.value = value
if value:
command_node = bashlex.parsesingle(value)
if len(command_node.parts) != 1:
raise ValueError('"%s" has too many parts' % value)
self.value_word_node = command_node.parts[0]
else:
self.value_word_node = None
def evaluated_value(self, environment):
'''Returns the value of this assignment, as evaluated in the environment'''
if self.value_word_node:
return bashlex_eval.evaluate_node(self.value_word_node, environment=environment)
else:
return ''
return bashlex_eval.evaluate(self.value, environment=environment)
def as_shell_assignment(self):
return 'export %s=%s' % (self.name, self.value)