Gentoo Logo
Gentoo Spaceship

Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-dev
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
To: gentoo-dev@g.o
From: Dan Douglas <ormaaj@...>
Subject: Re: lastpipe
Date: Fri, 25 May 2012 20:56:35 -0500
On Friday, May 25, 2012 08:52:00 PM Mike Frysinger wrote:
> On Friday 25 May 2012 18:33:43 Ciaran McCreesh wrote:
> > On Fri, 25 May 2012 15:02:32 -0500 Dan Douglas wrote:
> > > If it were made a policy now that ebuilds and eclasses cannot depend
> > > upon the subshell (for example, to set temporary positional
> > > parameters or isolate temporary variables), then maybe someday in the
> > > distant future this could be made the default, and in the meantime,
> > > an option for those with new enough shells. Since dependence on the
> > > subshell isn't very common, I think this should be feasible, and of
> > > course as a workaround all that's required is to wrap any such
> > > commands in parentheses.
> > 
> > We'll be able to turn that on in a controlled way in EAPI 6. Having
> > said that, if we're reaching the point where speed of bash code is
> > at all relevant, then ebuilds are doing something wrong...
> i don't think speed is the main motivator, but rather avoiding behavior that 
> bites new people all the time:
> 	count=0
> 	printf '%s\n' a b c | \
> 	while read line ; do
> 		: $(( count++ ))
> 	done
> 	echo $count
> w/out lastpipe, that shows 0.  w/lastpipe, that shows 3.
> -mike

Right, performance is just a nice side-effect. It makes a number of things 
cleaner (especially if the printf in that case were replaced with something 
more complicated), and is more intuitive for beginners .

However, all involved code needs to be able to expect lastpipe to always be 
either one way or the other, not mix-and-match. This means either EAPI 6 
requires Bash 4.2, or if Bash version detection is involved, a lot of the 
benefit to lastpipe is lost. Code which can't predict the behavior has to be 
written not only as though lastpipe were disabled, but also to account for the 
possility that it is enabled to avoid name conflicts.

In that example it would mean adding an explicit subshell, or saving and 
restoring the value of "line" before/after, or putting it into a function and 
using locals, or always making sure code executed after the loop initializes 
"line" to a known state.
Dan Douglas
signature.asc (This is a digitally signed message part.)
-- Dan Douglas
Re: lastpipe
-- Ciaran McCreesh
Re: lastpipe
-- Mike Frysinger
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: lastpipe
Next by thread:
Re: lastpipe
Previous by date:
Re: lastpipe
Next by date:
Re: comprehensive eclass checking in repoman

Updated Jun 29, 2012

Summary: Archive of the gentoo-dev mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.