Skip to content

Commit

Permalink
Handle empty echo correctly for cmd.
Browse files Browse the repository at this point in the history
Fixes #792
  • Loading branch information
bfloch committed Nov 8, 2019
1 parent 6db191f commit 9dcb402
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/rez/tests/test_shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def _print(value):
_print("ello")
_print(literal("ello"))
_print(expandable("ello"))
info('')
_print("\\")
_print("\\'")
_print("\\\"")
Expand Down Expand Up @@ -291,6 +292,7 @@ def _print(value):
"ello",
"ello",
"ello",
"",
"\\",
"\\'",
"\\\"",
Expand Down Expand Up @@ -331,8 +333,9 @@ def _print(value):

# We are wrapping all variable outputs in quotes in order to make sure
# our shell isn't interpreting our output as instructions when echoing
# it but this means we need to wrap our expected output as well.
expected_output = ['"{}"'.format(o) for o in expected_output]
# it but this means we need to wrap our expected output as well. Only
# exception is empty string, which is just passed through.
expected_output = ['"{}"'.format(o) if o else o for o in expected_output]

_execute_code(_rex_assigning, expected_output)

Expand Down
5 changes: 4 additions & 1 deletion src/rezplugins/shell/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ def info(self, value):
for line in value.split('\n'):
line = self.escape_string(line)
line = self.convert_tokens(line)
self._addline('echo %s' % line)
if line:
self._addline('echo %s' % line)
else:
self._addline('echo.')

def error(self, value):
for line in value.split('\n'):
Expand Down

0 comments on commit 9dcb402

Please sign in to comment.