Gentoo Archives: gentoo-dev

From: Alec Warner <antarus@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] new `usex` helper
Date: Tue, 13 Sep 2011 22:02:19
In Reply to: [gentoo-dev] new `usex` helper by Mike Frysinger
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} ; } 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 >


Subject Author
Re: [gentoo-dev] new `usex` helper Mike Frysinger <vapier@g.o>