Date: Fri, 25 Jun 2010 09:35:51 -0700 From: Patrick Mahan <mahan@mahan.org> To: Jilles Tjoelker <jilles@stack.nl> Cc: freebsd-hackers@freebsd.org Subject: Re: Help with some makefile hackery Message-ID: <4C24DAE7.1020809@mahan.org> In-Reply-To: <20100625133056.GA97679@stack.nl> References: <4C21A743.6040306@mahan.org> <20100625133056.GA97679@stack.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
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. >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C24DAE7.1020809>