commit dc1e011f3035646c81b54c265dff638ffe282ff1
Author: Bryn M. Reeves <bmr@redhat.com>
Date: Tue Aug 6 21:53:41 2013 +0100
Strip trailing newline from command output
This commit brings sos-3.x behaviour into line with earlier
releases and produces captured command output that is consistent
with typical shell redirection use.
Resolves: bz971420
diff --git a/sos/utilities.py b/sos/utilities.py
index fcc78c5..4279b12 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -161,6 +161,8 @@ def sos_get_command_output(command, timeout=300):
stdout=PIPE, stderr=STDOUT,
bufsize=-1, env = cmd_env)
stdout, stderr = p.communicate()
+ # hack to delete trailing '\n' added by p.communicate()
+ if stdout[-1:] == '\n': stdout = stdout[:-1]
return (p.returncode, stdout, 0)
else:
return (127, "", 0)