Skip to content

Commit

Permalink
Make getstatusoutput behaviour match library function (#733)
Browse files Browse the repository at this point in the history
subprocess.getstatusoutput strips a single trailing newline, if one exists. Some
calling code relies on this.
  • Loading branch information
TimoWilken authored Dec 3, 2021
1 parent 8b07dfa commit b8139bf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alibuild_helpers/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def getstatusoutput(command):
proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT,
universal_newlines=True, **kwargs)
merged_output, _ = proc.communicate()
# Strip a single trailing newline, if one exists, to match the behaviour of
# subprocess.getstatusoutput.
if merged_output.endswith("\n"):
merged_output = merged_output[:-1]
return proc.returncode, merged_output


Expand Down

0 comments on commit b8139bf

Please sign in to comment.