I'm writing a script which does something like the following:
echo -n "Doing stuff, wait for it... "
do_stuff
(($?==0)) && echo SUCCESS || echo FAILURE
Excuse the poor bash skills. Anyway, the problem is that the first part of the line doesn't get printed until do_stuff
is done - while it is important to me the user know what I'm running next. It is also important to me, since I'm pedantic, not to print a newline. So, the text is in the buffer and doesn't get flushed.
This question is very similar, but OP there was satisfied with, well, the way things are basically. I'm not. If push comes to shove I'm even willing to use something curses-related (but remember this is a shell script after all).
I think the appropriate thing to do is to turn off buffering:
stdbuf -i0 -o0 -e0 <command>
i = stdin
o = stdout
e = stderr
in your specific case you would only need -o0
for the standard output.