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: versionator.eclass: convert to eshopts_{push,pop}
Date: Mon, 19 Jul 2010 16:30:42 -0400
On Monday, July 19, 2010 16:07:56 David Leverton wrote:
> On 19 July 2010 20:43, Mike Frysinger <vapier@g.o> wrote:
> > On Monday, July 19, 2010 03:38:39 Ciaran McCreesh wrote:
> >> On Sun, 18 Jul 2010 20:17:45 -0700 Alec Warner wrote:
> >> > Can we do away with all the extra foo && return bullshit and just set
> >> > a trap?
> >> > 
> >> > trap "eshopts pop" RETURN
> >> > 
> >> >  ?
> >> 
> >> That strikes me as a horribly fragile way of doing things that's bound
> >> to come back and screw things up at some point...
> > 
> > nifty in theory, but i'm inclined to agree with Ciaran
> 
> Is something like the below function too hideous (not massively
> tested, but it seems to work)?  Usage is something like:
> 
> [dleverton@shiny-one ~] $ foo() { shopt -p extglob; }
> [dleverton@shiny-one ~] $ eshopts_need foo -s extglob

i imagine this might be useful in some scenarios, but i think the more common 
usage is to enable things inline.  otherwise, the exported API would need to 
be wrapped internally like:
get_all_version_components() {
	eshopts_need _get_all_version_components -s extglob
}

and at this point, it's hard to say this is better than just doing:
get_all_version_components() {
	eshopts_push -s extglob
	 _get_all_version_components 
	eshopts_pop
}

... or the existing code we have now.  although, the method we have now also 
allows for disabling of shopts before calling `die`.  not sure if that's 
important, but i think it's better to disable before all exit/termination 
points.

so unless their is a consumer now we can point to in the tree, i'm inclined to 
leave this alone.

> eshopts_need() {
>     [[ $# -ge 1 ]] || die "eshopts_need needs at least one argument"
>     local func=$1
>     shift
>     local opts=( "${@}" )
>     if [[ $1 == -[su] ]] ; then
>         eval "_eshopts_need_shopt_$(declare -f $func)"
>         eval "$func() {
>             local old=\$(shopt -p)
>             $(declare -p opts)
>             shopt \"\${opts[@]}\"
>             _eshopts_need_shopt_$func \"\$@\"
>             local status=\$?
>             eval \"\$old\"
>             return \$status
>         }"

there are already eshopts_push/pop funcs that accomodate more things than the 
usage here, but i imagine you did it this way just to make testing in your 
shell easier
-mike
Attachment:
signature.asc (This is a digitally signed message part.)
Replies:
Re: versionator.eclass: convert to eshopts_{push,pop}
-- David Leverton
References:
versionator.eclass: convert to eshopts_{push,pop}
-- Mike Frysinger
Re: versionator.eclass: convert to eshopts_{push,pop}
-- Mike Frysinger
Re: versionator.eclass: convert to eshopts_{push,pop}
-- David Leverton
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: versionator.eclass: convert to eshopts_{push,pop}
Next by thread:
Re: versionator.eclass: convert to eshopts_{push,pop}
Previous by date:
Re: Over using preserve_old_lib, don't do that
Next by date:
Re: versionator.eclass: convert to eshopts_{push,pop}


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.