Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,11 +1024,17 @@ def restore_output(self, statement):
if statement.parsed.pipeTo:
# Pipe output from the command to the shell command via echo
command_line = r'cat {} | {}'.format(self._temp_filename, statement.parsed.pipeTo)
result = subprocess.check_output(command_line, shell=True)
if six.PY3:
self.stdout.write(result.decode())
else:
self.stdout.write(result)

# Get the output and display it. Ignore non-zero return codes and print nothing.
try:
result = subprocess.check_output(command_line, shell=True)
if six.PY3:
self.stdout.write(result.decode())
else:
self.stdout.write(result)
except subprocess.CalledProcessError:
pass

os.remove(self._temp_filename)
self._temp_filename = None

Expand Down