From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 25 16:35:53 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47277106564A for ; Fri, 25 Jun 2010 16:35:53 +0000 (UTC) (envelope-from mahan@mahan.org) Received: from ns.mahan.org (ns.mahan.org [67.116.10.138]) by mx1.freebsd.org (Postfix) with ESMTP id 22CEA8FC1B for ; Fri, 25 Jun 2010 16:35:52 +0000 (UTC) Received: from Gypsy.mahan.org (crowTrobot [67.116.10.140]) by ns.mahan.org (8.13.6/8.13.6) with ESMTP id o5PGaqA4064990; Fri, 25 Jun 2010 09:36:53 -0700 (PDT) (envelope-from mahan@mahan.org) Message-ID: <4C24DAE7.1020809@mahan.org> Date: Fri, 25 Jun 2010 09:35:51 -0700 From: Patrick Mahan User-Agent: Thunderbird 2.0.0.22 (X11/20090605) MIME-Version: 1.0 To: Jilles Tjoelker References: <4C21A743.6040306@mahan.org> <20100625133056.GA97679@stack.nl> In-Reply-To: <20100625133056.GA97679@stack.nl> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Help with some makefile hackery X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2010 16:35:53 -0000 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; ./-kernel-toolchain.sh 2>&1 | tee > > 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. >