The following example Python program prints an updating progress bar.
progress.py :
import sys
import time
for i in range(100):
sys.stdout.write("\r%3d%%" % (i + 1))
sys.stdout.flush()
time.sleep(.02)
sys.stdout.write("\n")
However, when running it through GNU Make (from Bash on Ubuntu) with the following Makefile, the output appears to be buffered until the newline character is encountered, so the progress updates are not visible. Unbuffered output is specified to Python, just to be sure.
all :
python -u progress.py
Is there any way to get the partial-line output to be immediately visible when using make?
I eventually tracked this down to make
having been aliased with colormake
in our /etc/bash.bashrc
.
> type make
make is aliased to `colormake'
It seems colormake
buffers output. Presumably it needs to parse a whole line before colouring it.
This was fixed by adding:
unalias make
to ~/.bashrc
.
> type make
make is /usr/bin/make