diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2013-08-06 21:53:41 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2013-08-06 21:53:41 +0100 |
commit | 4a594b6dce129f8d9837c0d93768576badf2b2b7 (patch) | |
tree | 7b316beadde29a36e7f144e02266d320c8de885c | |
parent | d628ee46d638731de58dea3e28a06a253d4c56cb (diff) | |
download | sos-4a594b6dce129f8d9837c0d93768576badf2b2b7.tar.gz |
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
-rw-r--r-- | sos/utilities.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sos/utilities.py b/sos/utilities.py index fcc78c54..4279b12e 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) |