Jilles,

Thanks for the more complicated example.  I am always interested in
shell hacks like these, especially when they involve interesting uses
of file I/O redirection.

The tee is there so that the master build package (a perl script)
that builds not only my groups sources but other sources as well
is required to provide make 'output' for the master build log.

How is the status handled on compound commands?

   ./amd64-kernel.sh 2>&1 > build.log; tail -f build.log

would that obscure the exit status of the shell script as well? The
man page is not really clear on this.

Thanks,

Patrick

Jilles Tjoelker wrote:
On Tue, Jun 22, 2010 at 11:18:43PM -0700, Patrick Mahan wrote:
src-kern-tools:
     cd src; ./<machine>-kernel-toolchain.sh 2>&1 | tee <logfile>

The pipeline will return the status of 'tee' which is almost always 0.
The exit status of the build script is ignored.

A simple fix is store the status in a file and refer to that afterwards.
Another fix uses a separate file descriptor to pass through the status,
like
  { st=$(
    {
      { ./kernel-toolchain.sh 2>&1 3>&- 4>&-; echo $? >&3; } | tee logfile >&4
    } 3>&1)
  } 4>&1
but this is fairly complicated.

The issue can be sidestepped entirely by sending the output to a file
only; a developer can use tail -f to follow the build if necessary.

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to