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
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-dev@g.o
From: Mike Frysinger <vapier@g.o>
Subject: Re: Re: estack_{push,pop}: cool new helpers or over engineering?
Date: Fri, 16 Dec 2011 18:20:33 -0500
On Friday 16 December 2011 02:29:25 Steven J Long wrote:
> Mike Frysinger wrote:
> > +	[[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments"
> 
> ((..)) is quicker than [[ .. ]] for arithmetic stuff, and usually easier to
> grok swiftly.

i'm not used to using this style, so for now i think i'll keep the existing 
(and it's more common in Gentoo atm, or at least in the code base i sample, 
ignoring the obvious selection bias).  i'll noodle on this though and see if i 
can't convince myself to start using this and live migrating code in the tree.

> (($#)) || die .. is how this would normally be done.

i think this is a little less clear, but considering some of the 
[advanced/complicated] bash code i've written elsewhere in Gentoo, maybe 
that's a specious argument ...

> >  eshopts_push() {
> >  	if [[ $1 == -[su] ]] ; then
> > -		__ESHOPTS_SAVE__[$i]=$(shopt -p)
> > +		estack_push eshopts "$(shopt -p)"
> >  		[[ $# -eq 0 ]] && return 0
> 
> I'm not sure how this will ever match, given that $1 has been checked
> above? (($#==1)) && return 0 # if that applies (might be a 'bug'.)

the larger idea when i first wrote eshopts_{push,pop} was to not do any arg 
parsing at all, but then i hit the issue that `shopt` and `set` options are 
like a venn diagram -- a lot of common stuff, but each also has unique options.  
so i had to introduce a little arg parsing to make it actually work.  and the 
duplicated/forked code in the sub-branches were kept as similar as possible to 
(hopefully) make things simpler to read at a glance.  but that means sharper 
eyes notice a code branch which can never be hit as you've highlighted here.

as for the $#==1 check at the top, i don't want these helpers to require 
arguments as it would prevent more creative uses.  such as:
	eshopts_push
	. ./some-script-from-a-package
	eshopts_pop
but maybe that's not a big deal ...
-mike
Attachment:
signature.asc (This is a digitally signed message part.)
References:
estack_{push,pop}: cool new helpers or over engineering?
-- Mike Frysinger
Re: estack_{push,pop}: cool new helpers or over engineering?
-- Mike Frysinger
Re: estack_{push,pop}: cool new helpers or over engineering?
-- Steven J Long
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: estack_{push,pop}: cool new helpers or over engineering?
Next by thread:
Packages up for grabs due ian move to staffer
Previous by date:
Re: [gentoo-commits] gentoo-x86 commit in app-office/libreoffice: ChangeLog libreoffice-3.4.99.1.ebuild libreoffice-3.5.0.0.ebuild
Next by date:
Re: Removal of ChangeLog from eclass/ directory? (was: Re: [gentoo-commits] gentoo-x86 commit in eclass: autotools.eclass)


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.