Here's my observed behavior:
>>> out = subprocess.check_output("git gc", shell=True)
Counting objects: 4869, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1219/1219), done.
Writing objects: 100% (4869/4869), done.
Total 4869 (delta 3607), reused 4869 (delta 3607)
The operation output is printed in STDERR
. I wanted to capture this one in a variable too so I sent stderr to STDOUT
. But it does not capture it.
>>> out = subprocess.check_output("git gc", shell=True, stderr=subprocess.STDOUT)
>>> out
b''
>>> print(out)
b''
Any ideas/suggestions?
It seems that git gc is a special case where output redirection is not possible. Using typescript was recommended in the other question, but can someone with more knowledge explain that behavior? The script approach did not work as it did not exit the fork.