First, please refer to How to redirect stdout and stderr to a file and display stderr to console

This solution worked wonders for me. I invoked both scripts and commands as the command passed to bash -c. I even put wrote a global macro/function to make it easy to use (and avoid any typos or transpositions in the redirections). I happily used it many, many times.

Then I wrapped the magic invocation around

nice make -k -j 1 configure-host 

to start an build/install prepared by autotools. No make output was collected. In fact, each of the 3 make jobs (configure-host, all, install) put just 2 characters each into my log file.

Each outputfile consisted of 2 characters: an ascii zero and a return (0x300a). There should have been lines and lines generated by make.

I've been puzzling my head but don't see what's happening. Three relevant points:

  1. I'm running MSYS2 / MinGW-W64 (32 bit XP).
  2. make invokes autotools scripts that do lots of redirection using at least 6 FDs.
  3. The ../configure part of autotools does fine.

When I fall back to simple redirection

nice  make -k -j 1 configure-host &>logfile

I collect lots of both stdout and stderr together in the logfile (with a quiet terminal).

Here is my macro:

  log=$1; shift; rm -f ${LOGS}/${log}.log;
  bash -c "$@" 2>&1 >>$LOGS/${log}.log | tee --append $LOGS/${log}.log; }

Here is it's invocation:

export LOGS=/g/GNU-GCC/toolchain-avr/logs/D20161122.T023341
export MAKE_JOBS=1
CAPTURELOG build_gcc.configure-host nice make -k -j $MAKE_JOBS configure-host

Here is it's execution:

+ CAPTURELOG build_gcc.make.configure-host nice make -k -j 1 configure-host
+ log=build_gcc.make.configure-host
+ shift
+ rm -f /g/GNU-GCC/toolchain-avr/logs/D20161122.T023341/build_gcc.make.configure-host.log
+ bash -c nice make -k -j 1 configure-host
+ tee --append /g/GNU-GCC/toolchain-avr/logs/D20161122.T023341/build_gcc.make.configure-host.log
  • Funny when you write something up and then notice a clue? Here nice is the common element. nice does nothing in MinGW / Cygwin, and editing it out of the bash -c command text seems to solve the problem. – HiTechHiTouch Nov 30 '16 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.