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: Alec Warner <antarus@g.o>
Subject: Re: new `usex` helper
Date: Tue, 13 Sep 2011 15:01:25 -0700
On Tue, Sep 13, 2011 at 2:56 PM, Mike Frysinger <vapier@g.o> wrote:
> i keep writing little helpers like this in ebuilds:
> usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; }

usex...you naughty boy.

>
> this is so i can do:
>        export some_var=$(usex some_flag)
> and get it set to "yes" or "no"

If the intent is to use it for logic:

export some_var=$(usex some_flag)

if [[ $some_var == yes ]]; then
 # buttsex
fi

Then I recommend making true / false the default and then doing

if $some_var; then
  # buttsex
fi

If you are using it more like use_enable then...thats ok I guess ;p

-A

>
> or if i want something a little different, i can do:
>        export some_var=$(usex some_flag true false)
>        export some_var=$(usex some_flag y n)
>
> useful enough for EAPI ?  or should i just stick it into eutils.eclass ?  OR
> BOTH !?
> -mike
>


Replies:
Re: new `usex` helper
-- Mike Frysinger
References:
new `usex` helper
-- Mike Frysinger
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
new `usex` helper
Next by thread:
Re: new `usex` helper
Previous by date:
new `usex` helper
Next by date:
Re: new `usex` helper


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.