From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YPSzw-0001Gj-0Q for ptxdist@pengutronix.de; Sun, 22 Feb 2015 10:38:48 +0100 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1YPSzv-0002so-VB for ptxdist@pengutronix.de; Sun, 22 Feb 2015 10:38:47 +0100 Date: Sun, 22 Feb 2015 10:38:47 +0100 From: Michael Olbrich Message-ID: <20150222093847.GC1532@pengutronix.de> References: <1E9AED858BEB204B9DE4F807C7ED0EF617CDD326@EMSRVWIN2934.apps.edc.thyssenkrupp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1E9AED858BEB204B9DE4F807C7ED0EF617CDD326@EMSRVWIN2934.apps.edc.thyssenkrupp.com> Subject: Re: [ptxdist] (no subject) Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de On Sat, Feb 21, 2015 at 11:07:55PM +0000, R=FCdiger, Christoph wrote: > I'm trying to use ptxdist on a Mac OS X system to get rid of the Linux VM > just for compiling things. Here is the thing I stumbled upon because I > don't get the intention and therefore struggle to find a patch. > = > The git commit 0dc57566bc5a25d2b086de333844a3c00addf0e4 from 2012-12-13 > changed the body of the ptxd_make_log() function in scripts/libptxdist.sh > from this implementation > = > -ptxd_make_log() { > - # > - # fd3 =3D=3D stdout to logfile > - # fd4 =3D=3D stderr to logfile > - # fd5 =3D=3D clean stdout > - # fd6 =3D=3D clean stderr > - # > - { > - export PTXDIST_FD_STDOUT=3D5 > - export PTXDIST_FD_STDERR=3D6 > - export PTXDIST_FD_LOGFILE=3D7 > - { > - if [ -z "${PTXDIST_QUIET}" ]; then > - ptxd_make "${@}" 4>&- | > - # make's stdout on fd0 > - tee -a "${PTX_LOGFILE}" 2>&4 4>&- 5>&- 6>= &- > - check_pipe_status || return > - else > - exec 4>&- > - ptxd_make "${@}" 1>> "${PTX_LOGFILE}" > - fi > - } 2>&1 1>&3 3>&- 7>> "${PTX_LOGFILE}" | > - # make's stderr on fd0 > - tee -a "${PTX_LOGFILE}" 1>&2 3>&- 4>&- 5>&- 6>&- > - check_pipe_status || return > - } 3>&1 4>&2 5>&1 6>&2 > -} > = > to this implementation > = > +ptxd_make_log() {( > + # stdout only > + exec {PTXDIST_FD_STDOUT}>&1 > + # stderr only > + exec {PTXDIST_FD_STDERR}>&2 > + # logfile only > + exec 9>> "${PTX_LOGFILE}" > + export PTXDIST_FD_STDOUT > + export PTXDIST_FD_STDERR > + export PTXDIST_FD_LOGFILE=3D9 > + > + if [ -z "${PTXDIST_QUIET}" ]; then > + # stdout and logfile > + exec {logout}> >(tee -a "${PTX_LOGFILE}") > + else > + # logfile only > + exec {logout}>> "${PTX_LOGFILE}" > + fi > + # stderr and logfile > + exec {logerr}> >(tee -a "${PTX_LOGFILE}" >&2) > + > + ptxd_make "${@}" 1>&${logout} 2>&${logerr} > +)} > = > = > Now, my bash is complaining at the first exec command: > = > > exec: {PTXDIST_FD_STDOUT}: not found > = > = > To me, it looks fully understandable, because {PTXDIST_FD_STDOUT} is an > ill-formed brace expansion and is therefore ignored. But why is the Linux > (Ubuntu 12.04) not complaining about? > = > What is the intention of this brace usage here? It's valid bash syntax. A bit of history here: The standard for sh shells says, that the file descriptors up to 9 can be used inside the shell scripts. So that's what we used originally: With "5>&1" we create a file descriptor that we can later use to write to stdout when the normal stdout is redirected to the log file. However this solution as a problem: oder scripts can use the same file descriptor numbers and the output is send to the wrong place. This happened e.g. with configure scripts. So we changed it to: "exec {PTXDIST_FD_STDOUT}>&1". This is valid in bash and means that a new file descriptor is opened (with a currently unused number >=3D 10) and anything written to it is send to stdout. The file descriptor number is stored in the specified variable (PTXDIST_FD_STDOUT). I don't know why the bash in Max OS X cannot handle this. Maybe it's too old? What version are you using? Maybe something like this works: exec 7>&1 exec 8>&1 export PTXDIST_FD_STDOUT=3D7 export PTXDIST_FD_STDERR=3D8 Regards, Michael -- = Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- = ptxdist mailing list ptxdist@pengutronix.de